Jump to content


Passing a select option via url

  • Please log in to reply
2 replies to this topic

#1 Terry103

  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 23 September 2006 - 11:25 PM

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:


<title>Passing Variables</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<form action="test2.php" method="post" >
  <table width="100%" border="1">
      <td width="8%">&nbsp;</td>
      <td width="15%"><select name = 'card'>
          <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>

  // create short variable names
  $card = $_POST['card']; ?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<body><?php echo $card; ?>


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?

#2 mb81

  • Members
  • PipPipPip
  • Advanced Member
  • 120 posts

Posted 23 September 2006 - 11:32 PM

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.

#3 Terry103

  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 23 September 2006 - 11:54 PM

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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users