Terry103 Posted September 23, 2006 Share Posted September 23, 2006 Is there a way to pass the value from a drop-down select box via the url to another page:I can do it if I use a submit control, but that's not what I need to do.Here is a bare bones example:test.php<head><title>Passing Variables</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body> <form action="test2.php" method="post" > <table width="100%" border="1"> <tr> <td width="8%"> </td> <td width="15%"><select name = 'card'> <option>VISA <option>MasterCard <option>American Express</select></td> <td width="77%"><a href="test2.php?<?php echo "card="; echo $card; ?>">Add to Card </a><a href="test2.php?<?php echo "card="; echo $card; ?>"></a></td> </tr> </table> </form></body></html>test2.php:<?php // create short variable names $card = $_POST['card']; ?><html><head><title>Results</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><?php echo $card; ?></body></html>When I click on the 'Add to Cart' text, I can't figure out how to get the value from the 'card' control.Any help? Link to comment https://forums.phpfreaks.com/topic/21819-passing-a-select-option-via-url/ Share on other sites More sharing options...
mb81 Posted September 23, 2006 Share Posted September 23, 2006 Question #1: Why don't you want to do it as part of a submit function?Question #2: Are you trying to send it to the other page without leaving the page you are on?From what I see so far, it appears that you will have to do it with Javascript. Link to comment https://forums.phpfreaks.com/topic/21819-passing-a-select-option-via-url/#findComment-97438 Share on other sites More sharing options...
Terry103 Posted September 23, 2006 Author Share Posted September 23, 2006 I have a repeat region and a drop-down box on each line. It is populated from a database. When the user clicks on the add 2 cart button, it needs to send to the next page the option selected on that row so it can be saved in the cart data. ( My app is letting the user select a color)I am leaving the page I am on and opening the cart page. From the posted example, I need the url to contain 'card=VISA'. All I get is 'card=' and then an error stating that $card is an unknown variable. Link to comment https://forums.phpfreaks.com/topic/21819-passing-a-select-option-via-url/#findComment-97441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.