Jump to content


Photo

Two values to one radio button


  • Please log in to reply
2 replies to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 14 March 2006 - 11:59 AM

Dear all

I have a simple php page which has about 5 products on it, 3 of the products are the same price and 2 of the products are the same price, I have a radio button next to each product and the value of the radio button is the price of the product, so for example 9.99

I store this in a sql database, what I want to do is to pass another value with whatever radio button they select, this will be stored in the sql database and be able to tell me what the item code is.

For example

I have a radio button which is 9.99 and the item code is 3454334
I then have another radio button which is 9.99 and the item code is 1124565

Is there a way to pass a hidden value with a selected radio button? There would need to be a hidden field for each product, so I could pass the price and also the item code.

I was thinking about maybe an if statement, but as some of the radio button products values are the same price, im not going to be able to connect a if statement to the price of each product, if you see what I mean.

Has anyone been able to do this?

Any help would be great.

Thanks

Ed

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 14 March 2006 - 12:04 PM

you could set the radio button value to cost,code and then use..


$radio=explode(',',$_POST['radiobutton']);
$cost=$radio[0];
$code=$radio[1];


as far as i can think that should work fine :)
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 14 March 2006 - 12:21 PM

Fantastic, thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users