Radio Buttons w/ Multiple Values on a PHP Form

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

Yes you can do this.  If I were you I would eliminate the space in the value just to eliminate confusion.  Then when you process the variable use the Explode function ( http://php.net/manual/en/function.explode.php ) to separate the values in your string.  So if you eliminate the space your code would look like:
$_POST['option'] = $option;
$option = explode ("-",$option);
print $option[0]; //This would print the material
print $option[1]; //This would print the price
The only trick is your first two options don't have a color.  So your arrays would be different.  To offset this I would recommend that you use the same format for all options and make some sort of null value if nothing will be added for one value in the array, ie: color.

Similar Messages

  • Radio button variable not being emailed through php file.

    Dear Forum,
    I have a contact form in a AS 2.0 file that sends the form data just fine to my email. But it doesn't send the radio button selection variable.
    I am definately doing something wrong here.  Either with the setup of the radio buttons in flash, or with the php file.
    I was wondering if someone can tell me the error in my ways.
    I have included a screenshot of flash page, download link with all files, and the php code below.
    Any advice or help would be greatly appreciated.
    Thanks
    Jeff
    Boise, ID
    email: aaajeff<at>hotmail.com
    http://www.thevodkarevolution.com/email.zip
    http://www.thevodkarevolution.com/flashscreenshot.jpg
    Email.php file:
    <?php
    $sendTo = "[email protected]";
    $subject = "revolution - message";
    $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" .
    $_POST["email"] .">\r\n";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $headers .= "Return-path: " . $_POST["email"];
    $body = $_POST["name"] ." ". $_POST["email"] ." ". $_POST["message"] ." ".
    $_POST["industry"];
    mail($sendTo, $subject, $body, $headers);
    ?>

    I solve that problem, you also have to add the property
    radioButton1.setOnClick("common_timeoutSubmitForm(this.form, 'rbID');");
    and with this method will call the othe method :D
    Hope this is not too latte. :D

  • I made a fillable form using indesign and then acrobat professional but need to have radio buttons trigger different fields showing in the form below them - is that possible and if so how do I do it??

    I made a fillable form using indesign and then acrobat professional but need to have radio buttons trigger different fields showing in the form below them - is that possible and if so how do I do it??

    What version of Reader are they using, exactly? And are you sure they're
    using Reader itself and not opening the file inside a browser window, for
    example?
    On Fri, Feb 6, 2015 at 5:24 PM, jessicao96457206 <[email protected]>

  • I have a radio button that loses value on validation error

    Hi All,
    I have a radio button that is normal and then goes to readonly when a condition is true. The page has region with items as well as a tabular report region
    While in readonly state any validation error will cause the radio button to loose it's value.
    ?? Is this a bug or am I doing something wrong?
    Bill

    OK, Got the checkbox working...
    function SaveRes() {
    $x("P36_PRIORITY_RB").disabled=false;
    elmName = $x('P36_I_PRIORITY_0').name;
    elm = document.getElementsByName(elmName);
    for (i=0; i<elm.length; i++) {
    elm.disabled=false;
    doSubmit('SAVE');
    BUT ---- this part is now firing at the page rendering and doesn't fire when a validation is hit...
    DECLARE
    l_DynJS VARCHAR2(2000);
    BEGIN
    l_DynJS:='<script type="text/javascript"> '||chr(10)||
    ' $x("P36_PRIORITY_RB").disabled=true; '||chr(10)||
    ' elmName = $x(''P36_I_PRIORITY_0'').name; '||chr(10)||
    ' elm = document.getElementsByName(elmName);'||chr(10)||
    ' for (i=0; i<elm.length; i++) {              '||chr(10)||
    ' elm[i].disabled=true; '||chr(10)||
    ' } '||chr(10)||
    '</script>';
    htp.p(l_DynJS);
    END;

  • Help on Radio Buttons - Retreiving the value in a Servlet

    I am trying to use a Servlet to get values of list of Radio buttons in from a JSP. The problem is that I am getting a "null"
    My JSP has the following:
    <form name="AddNewClient" action="AddNewClient" method="POST">
    <input type="radio" name="TypeOfBusiness" value="Permanent Guarding" />Permanent Guarding (24/7)
    <input type="radio" name="TypeOfBusiness" value="Night Guarding" />Night Guarding
    <input type="radio" name="TypeOfBusiness" value="Interval Patrolling" />Interval Patrolling
    <td><input type="submit" value="Submit" name="Submit" /></td>
    </form>
    My Servlet has following:
    out.println (request.getParameter ("TypeOfService"));
    Anybody with an idea of what I am missing here. The drop-down list works just fine...but i dont want to use it
    Thanks in advance

    Gusha wrote:
    I am trying to use a Servlet to get values of list of Radio buttons in from a JSP. The problem is that I am getting a "null"Edited Code
    Please read it carefully its a simplest thing i can provide you :)
    function setSelection(choice)
         var select=0;
         select=choice;
         if(select=="Permanent Guarding")
              document.AddNewClient.Permanent Guarding.checked=true;
                                    document.AddNewClient.Night Guarding.checked=false;
              document.AddNewClient.Interval Patrolling.checked=false;
                                    document.AddNewClient.TypeOfBusiness.value="Permanent Guarding";
         if(select=="Night Guarding")
                                    document.AddNewClient.Permanent Guarding.checked=false;
                                    document.AddNewClient.Night Guarding.checked=true;
              document.AddNewClient.Interval Patrolling.checked=false;
                                   document.AddNewClient.TypeOfBusiness.value="Night Guarding";
         if(select=="Interval Patrolling")
                                    document.AddNewClient.Permanent Guarding.checked=false;
                                    document.AddNewClient.Night Guarding.checked=false;
              document.AddNewClient.Interval Patrolling.checked=true;
                                   document.AddNewClient.TypeOfBusiness.value="Interval Patrolling";
    </script>
    <form name="AddNewClient" action="AddNewClient" method="POST">
    <input type="radio" name="Permanent Guarding" value="Permanent Guarding"  onclick='setSelection(Permanent Guarding )'/>Permanent Guarding (24/7)<br />
    <input type="radio" name="Night Guarding" value="Night Guarding"  onclick='setSelection(Night Guarding)'/>Night Guarding<br />
    <input type="radio" name="Interval Patrolling" value="Interval Patrolling" onclick='setSelection(Patrolling)' />Interval Patrolling<br />
    <input type="hidden" value="" name="TypeOfBusiness" />
    <input type="submit" value="Submit" name="Submit" />
    </form>And get on the next page
    request.getParameter("TypeOfBusiness");Hope you get it
    Try and if any problem get back
    Sachin Kokcha

  • Radio Buttons - returning individual values from an exclusion group possible?

    Using LC Designer 7.1
    Does anyone know if it is possible to return individual values from an exclusion group of radio buttons?  My xml data file gives one value for the entire group, e.g.,
    2
    ...where the second radio button was selected.  But I'd prefer an output something like this...
      0
      1
      0
    etc...
    Is something in this format possible?

    You might be better off to use checkboxes and script them to act like radio buttons (as an exclusion group). That way they'd each have an on/off value.
    Regards,
    Dave

  • Dynamic radio button fields do not display again after form is saved

    Hello,
    I have a group of radio button questions within a dynamic form that display additional questions based on the answer.
    So for the question "Is there a basement?" if the user indicates yes, there is a basement, additional questions are displayed to gather more information about the basement. If the user indicates no, then those questions do not appear.
    Everything works beautifully in the form. However, when the form is saved and then re-opened, the additional questions do not appear in the form. So the structure goes from this:
    To this:
    The users must toggle the radio buttons to make those questions reappear...and when they do reappear, they have maintained whatever answer the user indicated before saving.
    I'm not sure why this is happening...does anyone have any advice?
    Thank you,
    Theresa

    Hi,
    Thanks so much for your response! I am using Designer 8.2.1.
    I just played around with more of my form...this seems to happen whenever I am working with a hidden subform that is displayed when the user clicks a button (or selects the appropriate radio button). I have a couple of other places within my form where this occurs.
    Here is an example of the script on one of those buttons:
    var intNewIndex = form1.construction_type.const_type_repeat.instanceManager.count-1; 
    form1.construction_type.resolveNode("const_type_repeat[" + intNewIndex + "]").percentage.presence="visible";
    const_type_repeat.instanceManager.addInstance(true);
    The script on the radio button is:
    if (basementyes.rawValue == 4){secondwd.sump.presence ="visible"
      secondwd.sumpradio.sumpyes.presence ="visible"
      secondwd.sumpradio.sumpno.presence ="visible"
    else {secondwd.sump.presence = "hidden"
      secondwd.sumpradio.sumpyes.presence = "hidden"
      secondwd.sumpradio.sumpno.presence ="hidden"
    I am pretty new at this so it might be something obvious...thanks again for your help!

  • Radio button data to php form

    I set up a survey, and I need the info from the radio button
    groups to send to a php form that will email me the results. So far
    I have not been able to get it to work. All I have so far is the
    code below attached to the submit button. I had a working contact
    form that I am trying to add radio buttons to, but they do not pass
    their info like the input text boxs do. I am a beginner with
    actionscript so I am having trouble finding where to get this to
    work. I have all my peramiters set on each radio button too. I just
    do not know what script to add to what I have so it will pass the
    data over to the php form.
    I have the survey as one MC which is inside a scroll pane if
    that matters. What I have so far can be seen here.
    http://ebinx.com/carrand/freestuffswf.swf
    Thanks

    bump

  • Radio Buttons for Flash PHP email.

    Hi.
    I need to add a sign-up form for services to a flash AS2 web site.
    I found a very simple example of a Flash/ PHP email form at Kirupa.
    It works fine, but I need to add some radio buttons.
    My web site will offer various services.
    Ideally I would like to be able for viewers to sign up for a service by clicking the appropriate right radio buttons
    F.ex;
    •   Service 1
    •   Service 2
    •   Service 3
    •   Service 4
    The email should reflect the choices made by listing the text on the selected services (radio buttons).
    Please download the FLA and the PHP file (at the bottom of the tutorial) here:
    http://www.kirupa.com/developer/actionscript/flash_php_email.htm
    I have uploaded a working version here:
    http://gggraphic.com/flash_mail/simple_flash_mail.php
    How do I add and script the radio buttons with both AS and the PHP to make it happen?
    Thank you on beforehand for your help
    ggaarde

    Hi Again
    Maybe check buttons would be a more natural option for this. You should be able to select more than one service.
    Thanks
    ggaarde

  • How to get radio button value in JavaScript

    I have a very simple radio button with two values: 1 and 2. I am trying to pass the value using a JavaScript call to a popup window. I am assuming there is a different method of obtaining the value, as
    var v_typ = document.getElementById("P1520_TYPE").value;doesn't work.

    Hi,
    If you are on Apex 3.x or higher, use JavaScript API function $v
    http://download.oracle.com/docs/cd/E14373_01/apirefs.32/e13369/javascript_api.htm#CHDEJEIG
    var v_typ = $v("P1520_TYPE");Regards,
    Jari

  • Setting/Clearing Dynamic Radio Button values

    Hi, i have the following Radio buttons defined within an iteration
    <c:forEach items="${searchresults}" var="post" varStatus="status">                                        
         <tr class = "text_results"> 
              <c:url value="/searchposts.do" var="url">
                   <c:param name="postitle" value="${post.postId.postTitle.title}"/>
                   <c:param name="postcode" value="${post.postId.postTitle.code}"/>                    
                   <c:param name="unitcode" value="${post.postId.units.unitCode}"/>
                   <c:param name="auth" value="${post.postId.auth}"/>
              </c:url>
              <td>
                   <a href='<c:out value = "${url}" />'>                                        
                   <c:out value="${post.postId.postTitle.title}"></c:out></a>
              </td>
              <td><c:out value = "${post.mustering}"/></td>  
              <td><c:out value = "${post.rank}"/></td>  
              <td>
                   <html:radio property="incmbt" 
                        value='${post.postId.postTitle.title}'>
                   </html:radio>                                             
                   <a href = "javascript:unCheckRadio(document.searchForm.incmbt)">
                        clear
                   </a>
              </td>                                             
         </tr> 
    </c:forEach>  The property "incmbt" is declared as a form property (String incmbt) with its getters and setters ... i plan to set each radio button with a value from database within an object called post. The actual value to set for each radio is a post title ... I seem to be getting a NULL value when i try to get the value in action class (form.getIncmbt() yields null) ... Am i assigning the value correctly?
    Further, here's is how i clear the values which seems to work
    Javascript
    function unCheckRadio(btngrp) {     
         for(var i=0; i < btngrp.length; i++)
              if( btngrp.checked == true ) {
                   btngrp[i].checked = false;
                   document.write("Selected Radio is :" + btngrp[i].value);
    But the "Selected Radio is :" displays "${post.postId.postTitle.title}", not the actual post title... ???

    I just thought about this quickly, i think its because an href link does not submit form values ... If so, how can i submit the value of a radio button through the <c:param/> tag or any other way after clicking the href link to submit the form?

  • Tab order of radio buttons skipping back

    I'm currently using Adobe Acrobat Pro XI (trial for now) to mess around with forms. I am having a problem right now with the tab order. I believe the culprits are a few pairs of radio buttons I have set up sequentially. Each pair is in it's own group with one being "Y" and the other "N". After setting the tab order such that I can easily navigate the form in the specified order, I have found that when I reach the bottom of the first page (the same page in which my radio buttons are found), with the last object that I "tab" through being a text field, I am redirected back up to the radio buttons instead of proceeding to the next tabulated object located on the next page. When I first tab through the radio buttons, the default value I land on is the "Y" value, and when I am unexpectedly redirected there again, the default value I land on is the "N" value of the first radio button. If I tab through everything to the bottom of the page, I am once again redirected back up to the radio buttons. If I mouse click on the next field on page 2 and tab through, everything works fine including being able to move onto page 3 in the expected order. So what gives? Why would I keep getting redirected back up to the radio buttons at the end of tabulating through page 1? I have the radio button groups in the correct tab order, but I'm not sure how to fix this issue with the radio buttons. Any help would be greatly appreciated. I have tried looking online in multiple places for a solution, but haven't quite found one to this or anyone else who might have this same problem. If any further clarification is needed, please let me know. Thanks!

    Make sure the thenames for all items including Checkboxes and radio buttons are unique on each page if go to adjust ment for tab order you can drag them to the correct order.
    even though you may have placed them at a specific spot if you added then at a later place in the design (say as an after thought, hey I need to add this), their tab order is based on when they are added not the position the actual element is placed.
    In other words if the check boxes /radio buttons are the fourth item down position wise in document by they were the twentith item added  they will skipped over thad the other 19 in turn will be tabbed to the when 20th tab is hit they will bounce back up to the check boxes/ Radio buttons.
    Be sure they are titled button1 button1a, button 2 button 2a and so on or lese the will be marked all at the same time and may bounce back to the first position they were in.

  • Overloaded radio buttons -- good GUI design?

    I don't know where else to ask this. What do you think about overloading radio buttons with multiple functions? I have made an update to my Interactive Color Wheel that uses this technique. I haven't released it yet, but it is available here:
    * http://r0k.us/rock/Junk/SIHwheel.html
    It offers eight different sorts of 1567 colors and their names. That seemed to me to be way too many radio buttons; there were originally just three sorts and three buttons. I made a second row that contains the five new sorts accessed via two buttons. The sorts on each button are closely related, riffs on a theme if you will. Consecutive clicks on one of these two buttons will rotate through its functions, with the button text and toolTip updated to match its current sort and state.
    I won't try describing more -- just use it, and let me know what you think. Intuitive? Ugly? Bad GUI design? Other comments?

    RichF wrote:
    Don't forget to take Spot, the Magic Color Dog for a walk! I recommend a different sort than the default [alphabetically], but you can change sorts on the fly. (Try [by hue], or one of the three Hilbert sorts.) In fact, Spot isn't stopping you from doing anything. Well, you'd have to have him go really slow to type in a hex color.
    I was really, really amazed how fast Spot can run. With the gauge fully to the right, the timer has a specified delay of 0, so he's running as fast as everything else in the program lets him. There's a LOT going on, yet Spot can traverse all 1567 colors in mere seconds.
    [add] It just occurred to me, maybe I should set a minimum update rate. I don't want it to cause someone to have an epileptic seizure. I'm thinking of setting 10 updates a second as the fastest it would go. What do you guys think?Actually it made me have to kill the JVM to stop the applet (closing the web page didn't work, apparently the new Java plugin sandboxing doesn't work). Only the JList was updating at full speed, not the color wheel.
    This one I did not do. There was a complication with intensity. It uses a quantized color space, with intensity almost ranging from 0..74. I say almost because this integral range also includes 0.5. I forced that in so the value after black on a 0.255 scale would not be 4, but 2. The third value is 4, and the rest of the time it jumps by 3 or 4 on the 255 scale.
    Once I decided to keep the intensity buttons as they were, it did not make sense to change the tile width buttons either. Their range is only 10..15, so IMO the [-] and [+] buttons work well.Just as a demo how to do that with JSpinner (JSlider is much harder to have non linear scales):
    import java.awt.EventQueue;
    import java.awt.FlowLayout;
    import javax.swing.JFrame;
    import javax.swing.JSpinner;
    import javax.swing.SpinnerNumberModel;
    public class TestJSpinner {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    SpinnerNumberModel rings = new SpinnerNumberModel(10, 10, 15, 1);
                    SpinnerNumberModel intensity = new SpinnerNumberModel(10.0, 0.0, 74.0, 1.0) {
                        @Override
                        public Object getPreviousValue() {
                            Double value = (Double) getValue();
                            if (value == 1.0) {
                                return 0.5;
                            else if (value == 0.5) {
                                return 0.0;
                            else {
                                return super.getPreviousValue();
                        @Override
                        public Object getNextValue() {
                            Double value = (Double) getValue();
                            if (value == 0.0) {
                                return 0.5;
                            else if (value == 0.5) {
                                return 1.0;
                            else {
                                return super.getNextValue();
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.getContentPane().setLayout(new FlowLayout());
                    frame.getContentPane().add(new JSpinner(intensity));
                    frame.getContentPane().add(new JSpinner(rings));
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
    }Edited by: Walter Laan on Nov 5, 2010 2:01 PM

  • Read-only radio button or checkboxes save as null

    Hi,
    I have a form with some fields that are editable by 1 group of users and read-only for another group in certain conditions.
    Before the header there is a fetch process to retrieve values from tables. So most fields (read-only & editable) are populated including checkboxes & radio buttons.
    All users can edit at least 1 field on the form.
    When the save button is pressed a PL/SQL process runs to save the data.
    The save works if the field is editable.
    If the field is read-only and text it also works.
    But if the field is a radio button or checkbox a null is saved in the table.
    Any suggestions on how to get the PL/SQL to pick up the read-only radio buttons and checkbox values?

    Hi,
    I had the same problem in my application and I found another solution instead of using two items. I'm using a computation on page processing that makes a select on my table to get the value for the checkbox. I'm doing this with the same condition as my read-only condition on my checkbox item so I can get the database value when it is lose in the submit process.
    Also, I found a difference in the html code between the read-only state of the item and the standard state.
    Original state : name="p_v07" (7 because it's the seventh item on my page)
    Read-only state : name="checkbox"
    I tried to modify this using firebug in execution of the page but without success, the problem is still there.
    Patrick
    Insum Solutions

  • Radio Button to make other field Mandatory

    I have two Radio Buttons that I want when clicked on (either one) to make a Number Field mandatory. I have viewed many websites on setting a mandatory field but the script I am using will not work. I have tried a couple ways of writing it but I seem to be missing something.
    I have used this script in the Show of: click & change
    Here is the script that I'm using right now.
    if  (this.rawValue==1)   
    AssemblyNu-1.mandatory ="error";
    else
    AssemblyNu-1.mandatory ="disabled";
    And this one:
    if (this.rawValue==2)
    AssemblyNu-1.mandatory ="error";
    else
    AssemblyNu-1.mandatory ="disabled";
    Thanks,
    HHud5757

    So, I put a quick form together to test your code.
    On the change event of the radio button list (not the radio button itself), I added:
    if (this.rawValue == 1) tfTest.mandatory = "error";
    else tfTest.mandatory = "disabled";
    In my case, the radio button with the value of 1 is the one I want to make the field mandatory. If you want either button to make it mandatory, then use:
    if (this.rawValue == 1 || this.rawValue == 2) tfTest.mandatory = "error";

Maybe you are looking for