Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variables through pages

Status
Not open for further replies.

Sitehelp

Technical User
Joined
Feb 4, 2004
Messages
142
Location
GB
Hello!
I want the user to be able to select an option from a list menu then submit the chosen variable to the next page. Below is my code and I am sure this is easy but I just cant get it to work????? any ideas please! Thanks


<select name=&quot;CallID&quot; size=&quot;1&quot; id=&quot;CallID&quot; title=&quot;<?php echo $row_OpenCallList['CallID']; ?>&quot;>
<?php
do {
?>
<option value=&quot;<?php echo $row_OpenCallList['CallID']?>&quot;><?php echo $row_OpenCallList['CallID']?></option>
<?php
} while ($row_OpenCallList = mysql_fetch_assoc($OpenCallList));
$rows = mysql_num_rows($OpenCallList);
if($rows > 0) {
mysql_data_seek($OpenCallList, 0);
$row_OpenCallList = mysql_fetch_assoc($OpenCallList);
}
?>
</select>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; onClick=&quot;&quot;>
 
the user selects a number from a list, then clicks submit, then the next page will say (for example): &quot;you have chosen number....&quot;

Cheers
 
Do u mean like this:?

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot;>
<select name=&quot;CallID&quot; size=&quot;1&quot; id=&quot;CallID&quot; title=&quot;<?php echo $row_OpenCallList['CallID']; ?>&quot;>
<?php
do {
?>
<option value=&quot;<?php echo $row_OpenCallList['CallID']?>&quot;><?php echo $row_OpenCallList['CallID']?></option>
<?php
} while ($row_OpenCallList = mysql_fetch_assoc($OpenCallList));
$rows = mysql_num_rows($OpenCallList);
if($rows > 0) {
mysql_data_seek($OpenCallList, 0);
$row_OpenCallList = mysql_fetch_assoc($OpenCallList);
}
$goto =&quot;['CallID'].&quot;&quot;;
?>
</select>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; onClick=&quot;$goto&quot;>
</form>

as its saying &quot;$goto is undefined&quot; and does nothing.

thanks for this!
 
I have no idea. Use of the OnClick attribute of the input tag takes you from the realm of PHP into the realm of JavaScript. Which is handled by a different forum.


What, in excruciating detail and without the posting of any code, are you trying to do?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
An example could be...

simply selecting a number from a list of 1-10, so I will choose 7 for example, then clicking submit, then the next page loads and says you have chosen the number 7.

 
form.html contains a POST-method form which contains a select tag named &quot;foo&quot; with options 1 through 10 and a submit button. The &quot;action&quot; attribute of this form is script.php.

script.php prints out $_POST['foo'].

form.htmlo:
Code:
<html><body><form method=&quot;post&quot; action=&quot;script.php&quot;>
<select name=&quot;foo&quot;>
   <option value=&quot;1&quot;>1</option>
   <option value=&quot;2&quot;>2</option>
   <option value=&quot;3&quot;>3</option>
   <option value=&quot;4&quot;>4</option>
   <option value=&quot;5&quot;>5</option>
   <option value=&quot;6&quot;>6</option>
   <option value=&quot;7&quot;>7</option>
   <option value=&quot;8&quot;>8</option>
   <option value=&quot;9&quot;>9</option>
   <option value=&quot;10&quot;>10</option>
</select>
<input type=&quot;submit&quot;></form></body><html>

script.php:
Code:
<?php
print '<html><body>You selected number ' . $_POST['foo'] . '.</body></html>';
?>


Or am I missing something fundamental here?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thanks I used that code, changed it a bit for the circumstance I wanted it for, but it works great, cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top