PDA

View Full Version : java/html form



rmosby
03-01-2006, 03:50 PM
Can anyone tell me why I can not get these two forms to work on the same page? Values shorted due to size.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Square Awning Cover</title>
</head>

<body>
<form method="POST" action="#" id="form1">
<p class="left" align="left"><font color="#FF7500" size="2">Square
Awning Cover</font></p>
<p class="left" align="left" style="margin-top: 0px"><font size="2">Fabric Class:</font><font size="1">
<select size="1" name="select1">
<option selected value="K">K</option>
<option value="P">P</option>
<option value="P+10">P+10</option>
<option value="P+15">P+15</option>
<option value="P+25">P+25</option>
<option value="P+80">P+80</option></select></font></p>
<p class="left" align="left" style="margin-top: 0px"><font size="2">Combined Drop &amp; Projection:
</font><font size="1"><select size="1" name="select2">
<option value="3-0" selected>3-0</option>
<option value="4-0">4-0</option>
<option value="5-0">5-0</option>
<option value="6-0">6-0</option>
<option value="7-0">7-0</option>
<option value="8-0">8-0</option>
<option value="9-0">9-0</option>
<option value="10-0">10-0</option>
<option value="11-0">11-0</option>
<option value="12-0">12-0</option></select></font><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Width:</font><font size="1"> <select size="1" name="select3">
<option value="3-0" selected>3-0</option>
<option value="4-0">4-0</option>
<option value="5-0">5-0</option>
<option value="6-0">6-0</option>
<option value="7-0">7-0</option>
<option value="8-0">8-0</option>
<option value="9-0">9-0</option>
<option value="10-0">10-0</option>
<option value="11-0">11-0</option>
<option value="12-0">12-0</option>
<option value="13-0">13-0</option>
<option value="14-0">14-0</option>
<option value="15-0">15-0</option>
<option value="16-0">16-0</option>
<option value="17-0">17-0</option>
<option value="18-0">18-0</option>
<option value="19-0">19-0</option>
<option value="20-0">20-0</option>
<option value="21-0">21-0</option>
<option value="22-0">22-0</option>
<option value="23-0">23-0</option>
<option value="24-0">24-0</option>
<option value="25-0">25-0</option>
<option value="26-0">26-0</option>
<option value="27-0">27-0</option>
<option value="28-0">28-0</option>
<option value="29-0">29-0</option>
<option value="30-0">30-0</option></select></font></p>
<p class="left" align="left" style="margin-top: 0px">&nbsp;</p>
<p class="left" align="center" style="margin-top: 0px"><font size="2">
<button type="submit" style="width: 92px; height: 22px"><font size="1">Get Dealer Cost</font>
</button></font>&nbsp;<input type="text" name="price" value="" readonly="readonly" size="5"></font><p class="left" align="center" style="margin-top: 0px">&nbsp;<script type="text/javascript">
<!--
function cost() {
var price=[];
price[0]=[
[93, 106, 117, 127, 136, 144, 161, 173, 200, 239],
[106, 117, 130, 139, 144, 161, 173, 200, 215, 263],
[356, 399, 413, 491, 504, 525, 599, 628, 673, 702]
];
price[1]=[
[109, 118, 133, 142, 151, 161, 179, 196, 228, 269],
[118, 133, 142, 151, 161, 179, 196, 228, 246, 297],
[415, 449, 482, 516, 557, 597, 638, 674, 710, 744]
];
price[2]=[
[121, 131, 147, 157, 167, 179, 199, 219, 255, 390],
[131, 147, 157, 167, 179, 199, 219, 253, 276, 428],
[460, 497, 534, 572, 617, 661, 705, 745, 784, 1204]
];
price[3]=[
[127, 138, 154, 165, 175, 188, 208, 230, 268, 396],
[138, 154, 165, 175, 188, 208, 230, 265, 291, 435],
[482, 521, 559, 600, 647, 693, 739, 781, 822, 1226]
];
price[4]=[
[139, 151, 169, 180, 191, 206, 228, 253, 295, 408],
[151, 169, 180, 191, 206, 228, 253, 290, 320, 448],
[527, 570, 611, 655, 706, 757, 807, 852, 896, 1271]
];
price[5]=[
[203, 224, 247, 263, 280, 304, 336, 378, 443, 472],
[224, 247, 263, 280, 304, 336, 378, 425, 484, 521],
[774, 835, 895, 962, 1035, 1107, 1177, 1242, 1305, 1518]
];
var f=document.getElementById('form1');
f['price'].value='$'+price[f['select1'].selectedIndex][f['select3'].selectedIndex][f['select2'].selectedIndex];
return false;}

if(document.getElementById) {
window.onload=function() {
document.getElementById('form1').onsubmit=cost;
document.getElementsByName('price')[0].type='text';
document.getElementsByName('price')[0].onfocus=function() {this.blur();};
};
}
//-->
</script><img src="images/hr02.gif" alt="" width="417" height="10" border="0"><form method="POST" action="#" id="form2">
<p class="left" align="left"><font color="#FF7500" size="2">Round
Awning Cover</font></p>
<p class="left" align="left" style="margin-top: 0px"><font size="2">Fabric Class:</font><font size="1">
<select size="1" name="select1">
<option selected value="K">K</option>
<option value="P">P</option>
<option value="P+10">P+10</option>
<option value="P+15">P+15</option>
<option value="P+25">P+25</option>
<option value="P+80">P+80</option></select></font></p>
<p class="left" align="left" style="margin-top: 0px"><font size="2">Combined Drop &amp; Projection:
</font><font size="1"><select size="1" name="select2">
<option value="3-0" selected>3-0</option>
<option value="4-0">4-0</option>
<option value="5-0">5-0</option>
<option value="6-0">6-0</option>
<option value="7-0">7-0</option>
<option value="8-0">8-0</option>
<option value="9-0">9-0</option>
<option value="10-0">10-0</option>
<option value="11-0">11-0</option>
<option value="12-0">12-0</option></select></font><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Width:</font><font size="1"> <select size="1" name="select3">
<option value="3-0" selected>3-0</option>
<option value="4-0">4-0</option>
<option value="5-0">5-0</option>
<option value="6-0">6-0</option>
<option value="7-0">7-0</option>
<option value="8-0">8-0</option>
<option value="9-0">9-0</option>
<option value="10-0">10-0</option>
<option value="11-0">11-0</option>
<option value="12-0">12-0</option>
<option value="13-0">13-0</option>
<option value="14-0">14-0</option>
<option value="15-0">15-0</option>
<option value="16-0">16-0</option>
<option value="17-0">17-0</option>
<option value="18-0">18-0</option>
<option value="19-0">19-0</option>
<option value="20-0">20-0</option>
<option value="21-0">21-0</option>
<option value="22-0">22-0</option>
<option value="23-0">23-0</option>
<option value="24-0">24-0</option>
<option value="25-0">25-0</option>
<option value="26-0">26-0</option>
<option value="27-0">27-0</option>
<option value="28-0">28-0</option>
<option value="29-0">29-0</option>
<option value="30-0">30-0</option></select></font></p>
<p class="left" align="left" style="margin-top: 0px">&nbsp;</p>
<p class="left" align="center" style="margin-top: 0px"><font size="2">
<button type="submit" style="width: 92px; height: 22px"><font size="1">Get Dealer Cost</font>
</button></font>&nbsp;<input type="text" name="price" value="" readonly="readonly" size="5"></font>
<script type="text/javascript">
<!--
function cost() {
var price=[];
price[0]=[
[93, 106, 117, 127, 136, 144, 161, 173, 200, 239],
[106, 117, 130, 139, 144, 161, 173, 200, 215, 263],
[117, 130, 141, 147, 161, 173, 207, 222, 246, 278],
[356, 399, 413, 491, 504, 525, 599, 628, 673, 702]
];
price[1]=[
[109, 118, 133, 142, 151, 161, 179, 196, 228, 269],
[118, 133, 142, 151, 161, 179, 196, 228, 246, 297],
[415, 449, 482, 516, 557, 597, 638, 674, 710, 744]
];
price[2]=[
[121, 131, 147, 157, 167, 179, 199, 219, 255, 390],
[131, 147, 157, 167, 179, 199, 219, 253, 276, 428],
[460, 497, 534, 572, 617, 661, 705, 745, 784, 1204]
];
price[3]=[
[127, 138, 154, 165, 175, 188, 208, 230, 268, 396],
[138, 154, 165, 175, 188, 208, 230, 265, 291, 435],
[482, 521, 559, 600, 647, 693, 739, 781, 822, 1226]
];
price[4]=[
[139, 151, 169, 180, 191, 206, 228, 253, 295, 408],
[151, 169, 180, 191, 206, 228, 253, 290, 320, 448],
[527, 570, 611, 655, 706, 757, 807, 852, 896, 1271]
];
price[5]=[
[203, 224, 247, 263, 280, 304, 336, 378, 443, 472],
[224, 247, 263, 280, 304, 336, 378, 425, 484, 521],
[774, 835, 895, 962, 1035, 1107, 1177, 1242, 1305, 1518]
];
var f=document.getElementById('form2');
f['price'].value='$'+price[f['select1'].selectedIndex][f['select3'].selectedIndex][f['select2'].selectedIndex];
return false;}

if(document.getElementById) {
window.onload=function() {
document.getElementById('form2').onsubmit=cost;
document.getElementsByName('price')[0].type='text';
document.getElementsByName('price')[0].onfocus=function() {this.blur();};
};
}
//-->
</script>

</body>

</html>

jscheuer1
03-03-2006, 04:07 PM
They are too similar and both access the onload event separately, with the second one's onload event overwriting the first's. You would need to come up with new names for price in the second one as well as a different name for the function cost there if the original version cannot suffice for both forms somehow. The two onload events would need to be combined while reflecting any changes made to the second script and its markup.