Jump to content

Form Checkbox Total.... Total Beginner needs help!


JohnnyBighead

Recommended Posts

Hello all, thanks for everything you do!

 

I used a php from generator to make the form seen on this page:

http://www.firstpresgreenville.org/forms/retirementform/retirementform-alt.html

 

I need to be able to click on the check boxes and get a dollar amount total in the total field....So if you checked "single", the total field would read $40, and if you checked on "couple", the field would read $50...simple as that...

 

Is there anyway to make that happen? 

 

This is the code I am working with now....

 

<?php

 

# This block must be placed at the very top of page.

# --------------------------------------------------

require_once( dirname(__FILE__).'/form.lib.php' );

phpfmg_display_form();

# --------------------------------------------------

 

 

 

function phpfmg_form( $sErr = false ){

        $style=" class='form_text' ";

 

?>

 

<form name="frmFormMail" action='' method='post' enctype='multipart/form-data' onsubmit='return fmgHandler.onsubmit();'>

<input type='hidden' name='formmail_submit' value='Y'>

<div id='err_required' class="form_error" style='display:none;'>

    <label class='form_error_title'>Please check the required fields</label>

</div>

           

           

<ol class='phpfmg_form' >

 

<li class='field_block' id='field_0_div'><div class='col_label'>

    <label class='form_field'>Full Name(s)</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <input type="text" name="field_0"  id="field_0" value="<?php  phpfmg_hsc("field_0"); ?>" class='text_box'>

    <div id='field_0_tip' class='instruction'></div>

    </div>

</li>

 

<li class='field_block' id='field_1_div'><div class='col_label'>

    <label class='form_field'>Street Address</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <input type="text" name="field_1"  id="field_1" value="<?php  phpfmg_hsc("field_1"); ?>" class='text_box'>

    <div id='field_1_tip' class='instruction'></div>

    </div>

</li>

 

<li class='field_block' id='field_2_div'><div class='col_label'>

    <label class='form_field'>City</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <input type="text" name="field_2"  id="field_2" value="<?php  phpfmg_hsc("field_2"); ?>" class='text_box'>

    <div id='field_2_tip' class='instruction'></div>

    </div>

</li>

 

<li class='field_block' id='field_3_div'><div class='col_label'>

    <label class='form_field'>State</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <input type="text" name="field_3"  id="field_3" value="<?php  phpfmg_hsc("field_3"); ?>" class='text_box'>

    <div id='field_3_tip' class='instruction'></div>

    </div>

</li>

 

<li class='field_block' id='field_4_div'><div class='col_label'>

    <label class='form_field'>Zip Code</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <input type="text" name="field_4"  id="field_4" value="<?php  phpfmg_hsc("field_4"); ?>" class='text_box'>

    <div id='field_4_tip' class='instruction'></div>

    </div>

</li>

 

<li class='field_block' id='field_5_div'><div class='col_label'>

    <label class='form_field'>Phone</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <input type="text" name="field_5"  id="field_5" value="<?php  phpfmg_hsc("field_5"); ?>" class='text_box'>

    <div id='field_5_tip' class='instruction'>(###) ###-####</div>

    </div>

</li>

 

<li class='field_block' id='field_6_div'><div class='col_label'>

    <label class='form_field'>Email</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <input type="text" name="field_6"  id="field_6" value="<?php  phpfmg_hsc("field_6"); ?>" class='text_box'>

    <div id='field_6_tip' class='instruction'></div>

    </div>

</li>

 

<li class='field_block' id='field_7_div'><div class='col_label'>

    <label class='form_field'>Number of Attendees</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <input type="text" name="field_7"  id="field_7" value="<?php  phpfmg_hsc("field_7"); ?>" class='text_box'>

    <div id='field_7_tip' class='instruction'></div>

    </div>

</li>

 

<li class='field_block' id='field_8_div'><div class='col_label'>

    <label class='form_field'>Single or Couple?</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <?php phpfmg_checkboxes( 'field_8', "Single|Couple" );?>

    <div id='field_8_tip' class='instruction'></div>

    </div>

</li>

 

<li class='field_block' id='field_9_div'><div class='col_label'>

    <label class='form_field'>Amount Due</label> <label class='form_required' >*</label> </div>

    <div class='col_field'>

    <input type="text" name="field_9"  id="field_9" value="<?php  phpfmg_hsc("field_9"); ?>" class='text_box'>

    <div id='field_9_tip' class='instruction'>$40/ single or $50/couple (Includes one book and lunch)</div>

    </div>

</li>

 

<li class='field_block' id='field_10_div'><div class='col_label'>

    <label class='form_field'>Additional Comments</label> <label class='form_required' > </label> </div>

    <div class='col_field'>

    <textarea name="field_10" id="field_10" rows=4 cols=25 class='text_area'><?php  phpfmg_hsc("field_10"); ?></textarea>

 

    <div id='field_10_tip' class='instruction'></div>

    </div>

</li>

<?php phpfmg_dependent_dropdown( 'field_11' );?>

 

            <li>

            <div class='col_label'> </div>

            <div class='form_submit_block col_field'>

   

                <input type='submit' value='Submit' class='form_button'>

                <span id='phpfmg_processing' style='display:none;'>

                    <img id='phpfmg_processing_gif' src='<?php echo PHPFMG_ADMIN_URL . '?mod=image&func=processing' ;?>' border=0 alt='Processing...'> <label id='phpfmg_processing_dots'></label>

                </span>

            </div>

            </li>

           

</ol>

   

</form>

 

<?php

           

    phpfmg_javascript($sErr);

 

}

# end of form

 

function phpfmg_form_css(){

?>

 

Thanks so much!

Link to comment
Share on other sites

 

Since your checkbox coding is not in the above code, I'll write it out.

 

<html>
<head>
<script type="text/javascript">
function addCheck() {
var s = document.getElementById('single');
var d = document.getElementById('double');
var t = document.getElementById('total');
if(s.checked == true) {
  t.value = 40;
}
if(d.checked == true) {
  t.value = 50;
}
}
</script>
</head>
<body>
<form>
<input type="radio" value="40" id="single" name="persons" onclick="addCheck();" /><label for="single"> Single</label><br />
<input type="radio" value="50" id="double" name="persons" onclick="addCheck();" /><label for="single"> Double</label><br />
<input type="text" value=0 id="total" name="total" /><label for="total"> Total</label>
</form></body>
</html>

 

This is only an example, load it up in your browser and see how it works.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.