Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Radio Buttons w/ Multiple Values on a PHP Form

New Here ,
Feb 21, 2010 Feb 21, 2010

Copy link to clipboard

Copied

Hi,

I have an Online Registration form with several options that each have their own prices.  I want the form results to show the name of each option the user selects, and the total of all the prices combined.  My question is how can I do that when each radio button only allows you to attach one value?  Is there a way to somehow retrieve the option name and price as two separate values?

<input name="option" type="radio" value="Cotton - $10" />

<input name="option" type="radio" value="Suede - $15" />

<input name="option" type="radio" value="Leather - Black - $20" />

<input name="option" type="radio" value="Leather - White - $20" />

For example, if they select 'Leather - Black - $20" I want to be able to retrieve one value of "Leather - Black" and another value of "20.00" (to add to the total price) rather than simply "Leather - Black - $20" in one value.

Any help would be greatly appreciated!  I've only had to deal with one value for each radio button in the past.

Thanks!

Paul

TOPICS
Server side applications

Views

1.8K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 22, 2010 Feb 22, 2010

Copy link to clipboard

Copied

No, a radio button can have only one value.

Use conditional logic in your processing to assign the price.

switch ($_POST['option') {

  case 'Cotton':

    $price = 10;

    break;

  case 'Suede':

    $price = 15;

    break;

  default:

    $price = 20;

}

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 22, 2010 Feb 22, 2010

Copy link to clipboard

Copied

I have just noticed that you posted an identical question in the main Dreamweaver forum, but didn't have the courtesy to mark this question as answered. Thanks for wasting my time.

Please do not post the same question in more than one forum. If you do, have the decency to follow up in all forums to say that your question has been answered.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2010 Feb 22, 2010

Copy link to clipboard

Copied

I didn't mark it answered because it wasn't.  You actually answered my question correctly though, which I really appreciate.  Thanks a lot!  I posted the same thing on both forums, because I figured I would get more response, which is exactly what happened.  Sorry if I hit a sensetive spot, but had I marked that thread as answered, I wouldn't have recieved your answer, which is much more what I was looking for.

Thanks, and have a great day.

Paul

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 22, 2010 Feb 22, 2010

Copy link to clipboard

Copied

LATEST

Please take a moment to read How to get help quickly.

You'll make life a lot easier for yourself and others if you stick by the suggestions there: don't post the same question in duplicate forums, keep a thread to a single subject, and mark threads as answered when you get the help you were looking for.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines