Hi, I was wondering if someone can help me with my script. Within the same page (using JavaScript), I would like publish values to form fields based upon user selection from a drop down list. You see similar examples for simple JavaScript shopping carts.
<!--- IN HEAD: --->
<script language="JavaScript" type="text/JavaScript">
<!--
function zip()
{
if(document.meddentrates.zip.value=="1") bcbsemployee=="50";
}
//-->
</script>
<!--- IN BODY: --->
<form name="meddentrates" id="meddentrates">
<table><tr>td>
Work Zip Code:
</td><td>
<select name="zip" id="zip">
<option value="0">Select an Office Location</option>
<option value="2">AL - Birmingham (35244)</option>
<option value="1">AL - Macon County (36083)</option>
<option value="3">AZ - Phoenix (85029)</option>
</select></td></tr>
<td>
<input type="submit" name="Submit" value="Display Rate" onclick="zip()" />
</td>
<!--- THEN BASED ON WHICH ZIP CODE THE USER SELECTS,
POPULATE THE FIELD "bcbsemployee" WITH A VALUE - in this case I choose 50. ---->
<tr>
<td>BCBS Plan</td>
<td><input name="bcbsemployee" type="text" id="bcbsemployee"/></td>
</tr>
In this case, if the user selects a zip code from the drop down list with a value of "1", how do I populate the "bcbsemployee" field with a value of 50? I have been playing around with my function and syntax, etc. but have not got it to work yet.
I have a follow-up question as well. I want to include if statements. So publish a set value to "bcbsemployee" based upon zip code and work status (radio button) and salary (drop down) list.
If "zip" == "1" & "status = "1" & salary = "1" THEN field "bcbsemployee" is populated with 50.
If "zip" == "1" & "status = "2" & salary = "2" THEN field "bcbsemployee" is populated with 75.
etc. I am not sure if I would have to write a seperate function for each of my if statements or now.
Thank-you for any help, Tony
<!--- IN HEAD: --->
<script language="JavaScript" type="text/JavaScript">
<!--
function zip()
{
if(document.meddentrates.zip.value=="1") bcbsemployee=="50";
}
//-->
</script>
<!--- IN BODY: --->
<form name="meddentrates" id="meddentrates">
<table><tr>td>
Work Zip Code:
</td><td>
<select name="zip" id="zip">
<option value="0">Select an Office Location</option>
<option value="2">AL - Birmingham (35244)</option>
<option value="1">AL - Macon County (36083)</option>
<option value="3">AZ - Phoenix (85029)</option>
</select></td></tr>
<td>
<input type="submit" name="Submit" value="Display Rate" onclick="zip()" />
</td>
<!--- THEN BASED ON WHICH ZIP CODE THE USER SELECTS,
POPULATE THE FIELD "bcbsemployee" WITH A VALUE - in this case I choose 50. ---->
<tr>
<td>BCBS Plan</td>
<td><input name="bcbsemployee" type="text" id="bcbsemployee"/></td>
</tr>
In this case, if the user selects a zip code from the drop down list with a value of "1", how do I populate the "bcbsemployee" field with a value of 50? I have been playing around with my function and syntax, etc. but have not got it to work yet.
I have a follow-up question as well. I want to include if statements. So publish a set value to "bcbsemployee" based upon zip code and work status (radio button) and salary (drop down) list.
If "zip" == "1" & "status = "1" & salary = "1" THEN field "bcbsemployee" is populated with 50.
If "zip" == "1" & "status = "2" & salary = "2" THEN field "bcbsemployee" is populated with 75.
etc. I am not sure if I would have to write a seperate function for each of my if statements or now.
Thank-you for any help, Tony