Hello All,
Right now I am building a rate calculator for my companies insurance products. I am using codeigniter framework and some javascript for showing divs based on a drop down selection.
My next goal is showing the data submitted in a form above the results, so they can easily edit and modify their input for a different search result, rather than filling out the whole form again.
The javascript I am using for hiding/showing divs is this:
<script type="text/javascript">$(document).ready(function() { $("#plan_type").change(function(){ id = $(this).val(); if ( id == "graded" ) { $("#tobacco").hide(); $("#faceGraded").show(); $("#faceLevel").hide(); $("#sex").show(); $("#age").show(); $("#adb").hide();
} else if ( id == "level" ) { $("#tobacco").show(); $("#faceLevel").show(); $("#faceGraded").hide(); $("#sex").show(); $("#age").show(); $("#adb").show(); } else if ( id == "default" ) { $("#tobacco").hide(); $("#faceLevel").hide(); $("#faceGraded").hide(); $("#sex").hide(); $("#age").hide(); $("#adb").hide();
} else { $("#tobacco").show(); $("#faceGraded").hide(); $("#faceLevel").hide(); } }); //inicial settings $("#tobacco").hide(); $("#faceGraded").hide(); $("#faceLevel").hide(); $("#sex").hide(); $("#age").hide(); $("#adb").hide(); });</script>
Here is an example of the PHP to output that drop down menu:
<?php $plan = $this->session->userdata('plan_type'); $options = array( 'default' =>'Select A Plan', 'graded' => 'Final Expense Graded Death Benefit', 'level' => 'Final Expense Level Death Benefit', ); ?> <?php echo form_dropdown('plan_type', $options, $plan,'id="plan_type"'); ?>
The 3rd parameter in form_dropdown is the default value. Which I have set to the ‘plan_type’ stored in a session from the previous submission.
The problem is, on the results page, even though I have ‘final_expense_level’ set as the default, it does not show that form. It hides.
Can anyone point me in the right direction!? I’ve been trying to find a solution for this and just can’t seem to do so.
Thanks ahead of time!
P.S. To see the script in action, http://newco.ratecal.info