SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member dzigner's Avatar
    Join Date
    Jul 2004
    Location
    USA
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question form and javascript

    Hello
    Is there a way to pass form values to 2 different html pages using javascript?
    I have one form, with instructions text field and resources text field. The instructions text field has to pass the entries to one page and the resources text field entries should go to resources file. Can someone tell me how to do it?
    Thanks in advance.

  2. #2
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Home
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you put an onsubmit event onto the <form> you can change characteristics of the form and tell it to do stuff, so that is the best way to do it. There is a few things we need to do to the form though to get it to submit to 2 different places:

    1. Submit the form
    2. Change the action and target
    3. Let the form submit itself automatically


    So, first we need to have the defaults put in place:

    Code:
    <form action="RESOURCES" target="_blank">
    If you just use that it submits to the resources page in a new window. So that's one page working. Now to just have the other page working. To do this we need to change the action with the this.action='' and the target in a similar manner. First though we need to tell it to submit for the first page with the this.submit() method. So, overall the code would be:

    Code:
    <form action="RESOURCES" target="_blank" onsubmit="this.submit() this.target=''; this.action='INSTRUCTIONS';">
    Having said all of that though, there would be a much better way to do it if you don't need to have it in 2 windows. If you had your script that handles the form can do everything in one page it will be much better as then it will work when JavaScript isn't enabled.

  3. #3
    SitePoint Evangelist vikrantkorde's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai, India
    Posts
    541
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes you can use the form property "action" and "target" to make it possible.

    you can also show the outpuyt in specific frame or in new page(default page anyway is possible). u just need to give the name of the frame or the page in the target property and the action indicates the page to be hit.
    Vikrant Korde
    S Y S T I M E, Mhape,
    Mumbai, Maharashtra, India.


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
  •