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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 values in the value property? 1

Status
Not open for further replies.

altctrldel

Technical User
Jul 26, 2003
30
is it possible to pass 2 values in a option/select/check box?

here is my current script:

Code:
<input name=\"planyr\" type=\"radio\" value=\"[b]$one[/b]\" checked=\"checked\" />1 Year Extended Warranty Plan (<strong>[b]$one[/b] dollars</strong>)

well it gets data from a row which has prices for 1, 2 and 3 years and displays them in three option boxes with their prices as the values.

Problem is that I want to also pass how many years they have selected along with the price when they submit the form so that I can also enter them into two seperate fields; lets say price and year.

I was thinking if I can use something like:

checkbox 1 = value=1$one
checkbox 2 = value=2$two
checkbox 3 = value=3$three

where in the first digit will be considered as the years and from the 2nd digit till the end would be considered as the price. But I don't know how to do that in php.

thank you for reading.
 
not sure whether you are going about it in the best way. might be better to put the number of years in a session variable or in a hidden field on the form. but you can do what you ask

Code:
<input name=\"planyr\" type=\"radio\" value=\"1_$one\" checked=\"checked\" />1 Year Extended Warranty Plan (<strong>$one dollars</strong>)

then parse the incoming value
Code:
function parsevalue($val) {
  $years = substr($val, 0,1);
  $value = substr($val, 2);
  return array("years"=>$years, "value"=>$val);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top