Re: Changing the Action attribute of Form

From: Date: Wed, 01 Nov 2006 15:33:00 +0000
Subject: Re: Changing the Action attribute of Form
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-244017@lists.php.net to get a copy of this message
<scipt language="javascript"> function change_action(obj) { if (obj.test_item.value="1") obj.action="page_1.php"; if (obj.test_item.value="2") obj.action="page_2.php"; return true; } </script> <form name="test" action="some_page.php" method="get" name="test"> <select name="test_item" size="1" onchange="return change_action(document.teste);"> <option value="1">Item 1</option> <option value="2">Item 2</option> </select> <input type="submit" name="submit" value="submit" /> </form> ""sues"" <skot1@twcny.rr.com> escreveu na mensagem news:02.4E.30579.92BB8454@pb1.pair.com... >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? Any help would be greatly > appreciated! > > Thanks!

« previous php.general (#244017) next »