SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    Miami FL
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript alert box redirecting to another form

    Alright, here's what I have...

    Theres a form (f1) once submitted it processes the form and it opens an alert box... alert box has two options, Yes or No, if Yes, another alert pops and thats it, if No, it goes to another form and it fills in the values of the previous form into the new form.... but in either case the first form is processed.

    my problems are two things...

    1) how do I code an alert box to have both yes and no answers and each answer going to a specified place

    2) once No is clicked in order to obtain the values in the previous form and use it on form 2, what can I do? Is this possible?

    The way I have it now is that the question is asked as a radio button option before f1 is submitted and depending on the choice, it does what its supposed to, and on the second form I retrieve everything using the $_POST array in php... but with this alert box being the decider, isnt the information in the first form lost?

    thanks for reading...

  2. #2
    SitePoint Zealot Valera Selev's Avatar
    Join Date
    Apr 2004
    Location
    Lviv, Ukraine
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fredo
    Alright, here's what I have...

    1) how do I code an alert box to have both yes and no answers and each answer going to a specified place

    2) once No is clicked in order to obtain the values in the previous form and use it on form 2, what can I do? Is this possible?
    1) javascript: use the confirm() function.
    2) you may submit form using GET method and then grab those values by javascript from page URL, or you may use server-side scripting to fill out the values of the second form.
    You may also have two forms on one page and hide/show them by javascript depending on your needs.

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    Miami FL
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you for your reply... but can you please elaborate on your 2nd answer? maybe by giving an example, I'm fairly new to js, thanks

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    Miami FL
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think GET would be a good answer, since I have so many things I would to transfer to the next page.. is there a way to use hidden fields and then transfer them using the pop up? basically can the options in the alert box act like a form submit and perform an action?


    I'm thinking once the submit button for F1 is clicked, the form is processed and the values are stored in hidden fields, then later using onSubmit, I open up an alert box which acts like another form and when NO is clicked it sends everything to F2...

    how is that?

  5. #5
    SitePoint Zealot Valera Selev's Avatar
    Join Date
    Apr 2004
    Location
    Lviv, Ukraine
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fredo
    I'm thinking once the submit button for F1 is clicked, the form is processed and the values are stored in hidden fields, then later using onSubmit, I open up an alert box which acts like another form and when NO is clicked it sends everything to F2...
    how is that?
    Mind that scripts can be turned off, so using server-side scripting is the best variant.

  6. #6
    SitePoint Zealot Valera Selev's Avatar
    Join Date
    Apr 2004
    Location
    Lviv, Ukraine
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fredo
    thank you for your reply... but can you please elaborate on your 2nd answer? maybe by giving an example, I'm fairly new to js, thanks
    Let's take a look at the variant using server-side scripting.
    The form's action property is set to a script which grabs the fields values set in F1.
    The same script generates F2 putting corresponding values to the needed places. That's it.

  7. #7
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    Miami FL
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah that is what i have done now and it works just like I wanted it to... thanks a lot Valera


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •