![]() |
| ||
| Onclick to pass a variable to a PHP script If I have the following code: <form> . . . <select id="lstOtherStuff" multiple="multiple" size="6" style="width:200px;"> </select> </form> and I need to pass the variable "1stOtherStuff" (which is an element in an array) to a PHP script, how do I do that? If I use the following code, I can access the file "welcome.php" (where I'd run a MYSQL script to query a value from a database): <form action="welcome.php" method="post"> Would there be another way to access this file, "welcome.php"? Or can I put the PHP script immediately after the Select script? I would like to also use an "onclick" command to initiate the action. So the user would press a button, after making a selection (the selection would then be stored in the variable "1stOtherStuff"). The selected value would then be sent to the PHP script and the PHP script would "echo" the value back. The main question I have though is how do I pass the variable, "1stOtherStuff", to the PHP/MySQL script... Your help would be appreciated! |
| ||
| Re: Onclick to pass a variable to a PHP script Quote:
$select_value = $_REQUEST['1stOtherStuff'];Here is a simple example. <?phpIf you don't use onchange event, then you can use a submit button. When the button is clicked, the value of select tag is passed to the calling script. <?phpIf you still have any doubts, let us know :) |
| ||
| Re: Onclick to pass a variable to a PHP script @mgt: Don't create multiple threads for the same topic. It ends up wasting the time of people who reply to those threads thinking there was no reply given. |
| All times are GMT -4. The time now is 3:42 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC