Forum Moderators: coopster

Message Too Old, No Replies

Passing Variables Multi-Page Form

I'm having trouble passing variables in a multi-page form

         

ryanhart

8:03 pm on Apr 10, 2009 (gmt 0)

10+ Year Member



I have a 4-step form (ex. quote.php, quote2.php, quote3.php, quote4.php).

I use PHP to pass the variables from quote.php to quote2.php, etc...

All the variables are passed successfully except TWO...
(insured_1_health_conditions and insured_1_health_conditions_detail)...
These 2 variables are located on quote2.php, then passed to quote3.php.

Below is the code for quote2.php:

JavaScript in Head Content


<script type="text/javascript">
<!--
function setConditions() {
document.getElementById("insured_1_health_conditions_detail").value=(((document.getElementById("aids").checked)?"HIV/AIDS / ":"")+""+((document.getElementById("diabetes").checked)?"Diabetes / ":"")+""+((document.getElementById("cancer").checked)?"Cancer / ":"")+""+((document.getElementById("heart-attack").checked)?"Heart Attack / ":"")+""+((document.getElementById("high-blood-pressure").checked)?"High Blood Pressure / ":"")+""+((document.getElementById("pregnant").checked)?"Pregnant / ":"")+""+((document.getElementById("stroke").checked)?"Stroke / ":"")+""+((document.getElementById("depression").checked)?"Depression / ":"")+""+((document.getElementById("other-illness").checked)?"Other major illness not listed. / ":""));
}

function unSetConditions() {
document.getElementById("aids").checked=false;document.getElementById("diabetes").checked=false;document.getElementById("cancer").checked=false;document.getElementById("heart-attack").checked=false;document.getElementById("high-blood-pressure").checked=false;document.getElementById("pregnant").checked=false;document.getElementById("stroke").checked=false;document.getElementById("depression").checked=false;document.getElementById("other-illness").checked=false;
document.getElementById("insured_1_health_conditions_detail").value="";
}
-->
</script>

QUOTE2.PHP FORM


<form action="quote3.php" method="post" name="healthquote" id="healthquote">

<!--VARIABLES PASSED FROM - HOME PAGE-->
<input type="hidden" name="address_1_state" id="address_1_state" value="<?=$_POST['address_1_state']; ?>" />

<!--VARIABLES PASSED FROM - QUOTE.PHP-->
<input type="hidden" name="insured_1_gender" value="<?=$_POST['insured_1_gender']; ?>">
<input type="hidden" name="insured_1_dobMM" value="<?=$_POST['insured_1_dobMM']; ?>">
<input type="hidden" name="insured_1_dobDD" value="<?=$_POST['insured_1_dobDD']; ?>">
<input type="hidden" name="insured_1_dobYYYY" value="<?=$_POST['insured_1_dobYYYY']; ?>">
<input type="hidden" name="insured_1_heightFT" value="<?=$_POST['insured_1_heightFT']; ?>">
<input type="hidden" name="insured_1_heightIN" value="<?=$_POST['insured_1_heightIN']; ?>">
<input type="hidden" name="insured_1_weight" value="<?=$_POST['insured_1_weight']; ?>">



<div class="mboxDefault">
<div id="inner-form">
<!--<div id="secure-lock"><span>Secure Form</span> <img src="_img/slock.jpg" /></div>-->
<table cellpadding="10" cellspacing="0" border="0" class="maintable">
<tbody>
<tr>
<td width="167" style="border-bottom: 1px solid #EFDCB4;">Currently Insured?</td>
<td width="77" style="border-bottom: 1px solid #EFDCB4;"><input type="radio" name="insured_1_currently_covered" id="insured_1_currently_covered" value="yes" />
Yes </td>
<td width="362" style="border-bottom: 1px solid #EFDCB4;"><input type="radio" name="insured_1_currently_covered" id="insured_1_currently_covered" value="no" checked />
No </td>
</tr>
<tr>
<td style="border-bottom: 1px solid #EFDCB4;">Smoker?</td>
<td style="border-bottom: 1px solid #EFDCB4;"><input type="radio" name="insured_1_smoker" id="insured_1_smoker" value="yes" />
Yes </td>
<td style="border-bottom: 1px solid #EFDCB4;"><input type="radio" name="insured_1_smoker" id="insured_1_smoker" value="no" checked />
No </td>
</tr>
<tr>
<td>Medical Conditions?</td>
<td><input type="radio" name="insured_1_health_conditions" id="insured_1_health_conditions_yes" value="yes" onClick="if(this.checked){document.getElementById('conditions').style.display='';}" />
Yes </td>
<td><input type="radio" name="insured_1_health_conditions" id="insured_1_health_conditions_no" value="no" onClick="if(this.checked){document.getElementById('conditions').style.display='none';}unSetConditions();" checked />
No </td>
</tr>
</tbody>
</table>
<table cellpadding="4" cellspacing="0" border="0" id="conditions" style="border-top: 1px solid #EFDCB4; display: none; margin-bottom: 10px; margin-right: 10px; margin-left: 10px; width: 565px;">
<tbody>
<tr>
<td width="139" style="padding-top: 10px;"><input type="checkbox" id="aids" onClick="setConditions();" />
HIV/Aids</td>
<td width="243" style="padding-top: 10px;"><input type="checkbox" id="diabetes" onClick="setConditions();" />
Diabetes</td>
<td width="272" style="padding-top: 10px;"><input type="checkbox" id="cancer" onClick="setConditions();" />
Cancer</td>
</tr>
<tr>
<td><input type="checkbox" id="heart-attack" onClick="setConditions();" />
Heart Attack</td>
<td><input type="checkbox" id="high-blood-pressure" onClick="setConditions();" />
High Blood Pressure</td>
<td><input type="checkbox" id="pregnant" onClick="setConditions();" /> Pregnant</td>
</tr>
<tr>
<td><input type="checkbox" id="stroke" onClick="setConditions();" />
Stroke</td>
<td><input type="checkbox" id="depression" onClick="setConditions();" />
Depression (requiring medication)</td>
<td><input type="checkbox" id="other-illness" onClick="setConditions();" />
Other Major Illness</td>
</tr>
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
mboxCreate('GHI-Quote_Step2_FormField_Mbox')
</script>
<div id="buttonCont">
<div class="mboxDefault">
<div id="buttons">
<input type="image" src="_img/continue-button-green.jpg" style="padding:0; padding-right: 20px; padding-top:0px;" onClick="return validateHealth2(this.form);" />
</div>
</div>
<script type="text/javascript">
mboxCreate('GHI-Quote_Step2_Button_Mbox')
</script>
</div>
</form>

Here are the hidden form fields for quote3.php


<!--VARIABLES PASSED FROM - HOME PAGE-->
<input type="hidden" name="address_1_state" id="address_1_state" value="<?=$_POST['address_1_state']; ?>" />

<!--VARIABLES PASSED FROM - QUOTE1.PHP-->
<input type="hidden" name="insured_1_gender" value="<?=$_POST['insured_1_gender']; ?>">
<input type="hidden" name="insured_1_dobMM" value="<?=$_POST['insured_1_dobMM']; ?>">
<input type="hidden" name="insured_1_dobDD" value="<?=$_POST['insured_1_dobDD']; ?>">
<input type="hidden" name="insured_1_dobYYYY" value="<?=$_POST['insured_1_dobYYYY']; ?>">
<input type="hidden" name="insured_1_heightFT" value="<?=$_POST['insured_1_heightFT']; ?>">
<input type="hidden" name="insured_1_heightIN" value="<?=$_POST['insured_1_heightIN']; ?>">
<input type="hidden" name="insured_1_weight" value="<?=$_POST['insured_1_weight']; ?>">

<!--VARIABLES PASSED FROM - QUOTE2.PHP-->
<input type="hidden" name="insured_1_smoker" value="<?=$_POST['insured_1_smoker']; ?>">
<input type="hidden" name="insured_1_currently_covered" value="<?=$_POST['insured_1_currently_covered']; ?>">
<input type="hidden" name="insured_1_health_conditions" value="<?=$_POST['insured_1_conditions']; ?>">
<input type="hidden" name="insured_1_health_conditions_detail" value="<?=$_POST['insured_1_health_conditions_detail']; ?>">

[edited by: coopster at 10:47 pm (utc) on April 10, 2009]
[edit reason] no personal urls please TOS [webmasterworld.com] [/edit]

coopster

12:15 pm on Apr 17, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, ryanhart.

That's quite a bit of code and likely why there aren't too many responses. However, it looks to me like you are trying to use an element by ID (

insured_1_health_conditions_detail
) which has not been defined in the form anywhere.