Re: Changing the Action attribute of Form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



# skot1@xxxxxxxxxxxx / 2006-11-01 10:20:07 -0500:
> I need to pass control of a form to either a page that accesses our 
> database, and displays the data, OR to a page that contains static content. 
> The ACTION attribute will then depend on the contents of 1 of the input 
> fields in the form, which is a SELECT type of input. Here is an example of 
> what the form looks like:
> 
> <form id="test" action="some_page.php" method="get" name="test">
>  <select name="test_item" size="1">
>       <option value="1">Item 1</option>
>       <option value="2">Item 2</option>
> </select>
> <input type="submit" name="submit" value="submit" />
> </form>
> 
> If "Item 1" is selected, I want to go to a certain page (some_page.php), and 
> if "Item 2" is selected I want to go to a different page.  Is there a way to 
> handle this using PHP or JavaScript?

    Javascript: Have the submit button call a JS function which would
    check the state of the select and set the action appropriately
    before submitting the form.

    PHP: submit the result to a dispatcher script that'll redirect to
    one of the targets based on what has arrived in the data (you'll
    lose the ability to POST though).

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux