Hello,
Apologies, this JavaScript not PHP. (The suggestion originally came form this forum). I'm using this script to create a second form value (Cost) that depends on the answer to another form value (Booth).
<head>
<script type="text/javascript">
function getIPut(val)
{
var state = document.getElementById('Booth1').value;
var loca;
if(booth == 'large - $950'){
loca = '950';
}else if(booth == 'medium - $850'){
loca = '850';
}else if(booth == 'small - $750'){
loca = '750';
}
document.getElementById('Cost1').value = loca;
}
</script>
</head>
Booth type:
<label>
<select onchange="getIPut();" id="Booth1" name="Booth1">
<option value=""></option>
<option id="booth" value="large - $950">large - $950</option>
<option id="booth" value="medium - $850">medium - $850</option>
<option id="booth" value="small - $750">small - $750</option>
</select>
</label>
<input id="Cost2" type="hidden" name="Cost1" />
It works fine, until I try to duplicate it (two "Booths" and two "Costs")... I've tried hard-coding it as well as this:
<head>
<script type="text/javascript">
function getIPut(val)
{
for (var i = 1; i <= 2; i++ )
{
var state = document.getElementById('Booth'+i).value;
var loca;
if(booth == 'large - $950'){
loca = '950';
}else if(booth == 'medium - $850'){
loca = '850';
}else if(booth == 'small - $750'){
loca = '750';
}
document.getElementById('Cost'+i).value = loca;
}
}
</script>
</head>
Booth type:
<label>
<select onchange="getIPut();" id="Booth1" name="Booth1">
<option value=""></option>
<option id="booth" value="large - $950">large - $950</option>
<option id="booth" value="medium - $850">medium - $850</option>
<option id="booth" value="small - $750">small - $750</option>
</select>
</label>
<input id="Cost2" type="hidden" name="Cost1" />
<p />
Booth type:
<label>
<select onchange="getIPut();" id="Booth2" name="Booth2">
<option value=""></option>
<option id="booth" value="large - $950">large - $950</option>
<option id="booth" value="medium - $850">medium - $850</option>
<option id="booth" value="small - $750">small - $750</option>
</select>
</label>
<input id="Cost2" type="hidden" name="Cost2" />
Nothing seems to work... I've tried renaming the "getIPut" events as well, in case they were conflicting.
I've been at this simple chore for hours.
Thanks for reading.
~Wayne