PDA

View Full Version : getting a button to interact with dropdown and then output



shadybuck
12-13-2010, 09:40 PM
I feel like I am really close on getting this script to work, but I still think something is off, I am trying to make it so my dropdown tabs change what the output boxes will read for an estimate of gangway prices and weights dependant on their lengths and widths, but so far no luck in getting it to work

here is the javascript that I have in my heading


<script language="JavaScript" type="text/javascript">

//calculate function
function calculate(1234){

//variables
var widthValue = document.getElementById('width');
var lengthValue = document.getElementById('length');
var transition plate = 400;
var width = a;
var length = b;
var c = transition plate;
var d = Math.round(a*1.76*2.2*(b/5 + 1));
var e = Math.round(b*2*.4*2.2);
var f = Math.round(a*b*1.95*2.5);
var g = Math.round(3.814*2.2*(4*(b/10) + 2));
var h = Math.round(b*2*3.85*2.2);
var i = Math.round(37.5625*1.264*2.2*(4*(b/10) + 2)/12);
var j = Math.round((b*4*69*1.264*2.2/120);
var k = Math.round(1.264*2.2*(b*2 + 3.5));
var m = Math.round(b*6.3);
var n = Math.round(b*1.38);
var o = Math.round(b*3.2);
var priceValue = Math.round(d + e + f + g + h + i + j + k + m + n + o + 85);
var weightValue = ((d/2.2) + (e/2.2) + (f/2.5) + (g/2.2) + (h/2.2) + (i/2.2) + (j/2.2) + (k/2.2) + (m/7) + (n/1.5) + (o/3.5) + 40;

if (c = true)
{
var price = Math.round(d + e + f + g + h + i + j + k + m + n + o + 85 + c);
}

object.finalPrice.value = priceValue;
object.finalWeight.value = weightValue;
}
</script>


and here is the html in my body that I want to interact with the java


<table align="center" border="0" name="tab1">
<tbody>
<tr>
<td align="right">Width: </td>
<td align="left"><select id="widthValue">
<option selected="selected">3'</option>
<option value="4">4'</option>
<option value="5">5'</option>
</select> </td>
</tr>
<tr>
<td align="right">Length: </td>
<td align="left"><select id="lengthValue">
<option selected="selected">20'</option>
<option value="25">25'</option>
<option value="30">30'</option>
<option value="35">35'</option>
<option value="40">40'</option>
<option value="45">45'</option>
<option value="50">50'</option>
</select> </td>
</tr>
<tr>
<td>Transition Plate: </td>
<td align="left"><input name="Transtion Plate" id="chkbx" type="checkbox" value="on" /> </td>
</tr>
<tr>
<td align="center" colspan="2"><input onclick="calculate(1234);" type="button" value="Calculate" /> </td>
</tr>
<tr>
<td align="right">Price: </td>
<td alig="left">$<input name="finalPrice" type="text" size="4" readonly="readonly" /> </td>
</tr>
<tr>
<td align="right">Weight: </td>
<td alig="left"><input name="finalWeight" type="text" size="5" readonly="readonly" />lbs. </td>
</tr>
</tbody>
</table>
<br />

Any advice on how to get this working would be greatly appreciated
thanks all