Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Dynamic Radio Button validate/displaying
Old 02-08-2012, 10:25 PM Dynamic Radio Button validate/displaying
Novice Talker

Posts: 9
Trades: 0
Hi Folks

Need some massive help. I am trying to do a registration page and in this page there are various options for users to choose.

Based on what they have chosen, they will be shown the price.
The choices is done by different radio button groups.

I have been trying to do dynamic checking of the radio button and displaying the results using if/if else conditions that adds up different value.

The results of the radio button does not seems to be captured.
HTML Code:
  <h2><span>Registration</span></h2>
          <div class="clr"></div>
          <p><font color="#009966">Registration Selection</font> <br /><font size="-5">Price includes 7% GST</font>        </p>
             <p><font color="#009966">Please select one. Do note that if you are a delegate, your package includes the banquet</font></p>
            <p>
              <label>
                <input type="radio" name="f" value="856" id="RadioGroup1_0" />
                F1 Standard</label>
              <br />
              <label>
                <input type="radio" name="f" value="535" id="RadioGroup1_1" />
                F2 Students</label>
              <br />
            </p>

        <p><font color="#009966">Please select one. If you have selected the CB3, please indicate how many pax in the field below.</font></p>
          <p>
            <label>
              <input type="radio" name="cb" value="0" id="RadioGroup2_0" />
              CB1 Conference Delegate (Category F1)</label>
            <br />
            <label>
              <input type="radio" name="cb" value="100" id="RadioGroup2_1" />
              CB2 Students</label>
            </p>
            <p>
            <label>
            <input name="ap" type="radio" value="120" />Accompanying Person</label>
            </p>
          <p>
            <label>Number of pax for above
              <input type="text" name="person" id="person" />
            </label>
          </p>
PHP Code:
   <?php
             
             $value 
0;
             echo 
$f;
             echo 
$cb;

            if (
$f == 856 && $cb == 0)  
            {
                
$value 856;
                echo 
"1";
            }
            else if (
$f == 856 && $cb == 100 && $ap == "")  
            {
                
$value 856;
                echo 
"You are already covered for banquet and the selection you have check is for students";
            }
            else if (
$f == 856 && $cb == && $ap == 120)  
            {
                
                
$value = ($person 120) + 856;
                echo 
"You are already covered for banquet and the selection you have check is for students";
            }
            else if (
$f == 535 && $cb == && $ap == "")
            {
                
$value 535;
                echo 
"You have indicated that you are a student and that does not entitled you to the banquet unless you have selected the second option";
            }
            else if (
$f == 535 && $cb == 100 && $ap == "")
            {
                
$value 635;
            }
            else if (
$f == 535 && $cb == 100 && $ap == 120)
            {
                
$value = ($person 120) + 100 856;
            }
            echo 
$value;
            
?>
             
             <p><font color="#009966">From your selection, you will have to pay $<?php echo $value?>.</font></p>
If anyone can point out any mistake i have made or suggest a better way of doing this, i will be grateful ...

thanks all for reading !!

Last edited by NullPointer; 02-09-2012 at 01:48 PM..
luconis is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-09-2012, 01:50 PM Re: Dynamic Radio Button validate/displaying
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
It looks like you are expecting register globals to be enabled, but it isn't. Try using $_POST['f'] instead of $f.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-09-2012, 08:52 PM Re: Dynamic Radio Button validate/displaying
Novice Talker

Posts: 9
Trades: 0
tried using $_POST['f'] instead of $f for the checks but it is still not dynamically showing the $value.

Could I have define it wrongly ?
luconis is offline
Reply With Quote
View Public Profile
 
Old 02-09-2012, 09:41 PM Re: Dynamic Radio Button validate/displaying
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
I'd like to see full HTML - ie with form tag and submit. Then I'd expect to see the processing branch subject to an "if submitted".
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 02-10-2012, 01:30 AM Re: Dynamic Radio Button validate/displaying
Novice Talker

Posts: 9
Trades: 0
Hi PaulW

I have not place them under a form to be submitted because i need them to be read dynamically to the users at the current page when they select the radio button
luconis is offline
Reply With Quote
View Public Profile
 
Old 02-10-2012, 04:44 AM Re: Dynamic Radio Button validate/displaying
Skilled Talker

Posts: 50
Trades: 0
Something like this http://www.javascript-coder.com/file.../cakeform.html
HullBorn is offline
Reply With Quote
View Public Profile
 
Old 02-12-2012, 08:42 PM Re: Dynamic Radio Button validate/displaying
Novice Talker

Posts: 9
Trades: 0
Yes HullBorn !!! Anywhere i can find some demo codes for that ???
luconis is offline
Reply With Quote
View Public Profile
 
Old 02-13-2012, 05:47 AM Re: Dynamic Radio Button validate/displaying
Skilled Talker

Posts: 50
Trades: 0
http://www.javascript-coder.com/java...r-script.phtml
HullBorn is offline
Reply With Quote
View Public Profile
 
Old 02-14-2012, 02:47 AM Re: Dynamic Radio Button validate/displaying
Novice Talker

Posts: 9
Trades: 0
Hi HullBorn

Thanks for the help ... I have done it but encounter another issue.

As I need to post these values in a form with the tabulated totalprice as of below

<form id="frmPaymentCC" method="post" action="https://xxxxxxx/xxxx/xxxx/xxx/xx">
<input name="mid" type="hidden" value="20100824004">
<input name="ref" type="hidden" value="<?php $projectCode; echo $projectCode; ?>">
<input name="cur" type="hidden" value="SGD">
<input name="amt" type="hidden" value="totalprice()">
<input name="returnurl" type="hidden" value="http://icius2012.com/icius2012/register_done.php">
<input name="skipstatuspage" type="hidden" value="">
<input type="submit" name="button" value="Register">
</form>

The one reflected totalprice() is the one that is calculated when the users choose the options with the radio buttons ...

Will need to know how am i going to grab that value instead of using id="" which cannot be used in this case.

Thanks for the help !!
luconis is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Dynamic Radio Button validate/displaying
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.37491 seconds with 12 queries