Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Dropdown Form Values

Status
Not open for further replies.

corexdev

Programmer
May 11, 2015
7
0
0
US
i Have the Following Code and was Wanting to try and get all values selected to add up or Subtract from Initial Value shown, I've tried to work on this and Kind of stuck, can anyone help me out... thanks all

#// --------CODE START --------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Items Values add Subtract</title>
<style type="text/css">
<!--
.style5 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }
.style7 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; }
-->
</style>
</head>

<body>
<form action="submit.php" method="get" name="submit">
<table width="235" border="0" cellpadding="1" cellspacing="1">
<tr>
<td width="225" colspan="2"><span class="style5">Item Value1
<select name="Values1" onChange="">
<option name="Val0-0" value="$00.00">-----Select-------</option>
<option name="Val1-1" value="$32.00">ItemValue1</option>
<option name="Val1-2" value="$52.00">ItemValue2</option>
<option name="Val1-3" value="$82.00">ItemValue3</option>
</select>
</span></td>
</tr>
<tr>
<td colspan="2"><span class="style5">Item Value2
<select name="Values2" onChange="">
<option name="Val2-0" value="$00.00">-----Select-------</option>
<option name="Val2-1" value="$32.00">ItemValue1</option>
<option name="Val2-2" value="$52.00">ItemValue2</option>
<option name="Val2-3" value="$82.00">ItemValue3</option>
</select>
</span></td>
</tr>
<tr>
<td colspan="2"><span class="style5">Item Value3
<select name="Values3" onChange="">
<option name="Val3-0" value="$00.00">-----Select-------</option>
<option name="Val3-1" value="$32.00">ItemValue1</option>
<option name="Val3-2" value="$52.00">ItemValue2</option>
<option name="Val3-3" value="$82.00">ItemValue3</option>
</select>
</span></td>
</tr>
<tr>
<td colspan="2"><span class="style5">Item Value4
<select name="Values4" onChange="">
<option name="Val4-0" value="$00.00">-----Select-------</option>
<option name="Val4-1" value="$32.00">ItemValue1</option>
<option name="Val4-2" value="$52.00">ItemValue2</option>
<option name="Val4-3" value="$82.00">ItemValue3</option>
</select>
</span></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">Initial Value: <span class="style7">$378.00 </span></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit Selection">
</div></td>
</tr>
<tr>
<td colspan="2"><span class="style5">Values Total: </span></td>
</tr>
</table>


</form>
</body>
</html>
 
And the code you have tried is??

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
heheh "the code i tried is??",

<head>
<script type="text/javascript">
function doEcho(objForm)
{
var total=0;
for (var i=1;i<=5;i++){
objSelect = objForm.elements["var" + i];
total += Number(objSelect.options[objSelect.selectedIndex].value);
}
objForm.display.value = total;
}
</script>
</head>
<body>
<form name="echo">
<select name="var1" onChange="doEcho(this.form)">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select name="var2" onChange="doEcho(this.form)">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select name="var3" onChange="doEcho(this.form)">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select name="var4" onChange="doEcho(this.form)">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select name="var5" onChange="doEcho(this.form)">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select><br>

<input type="text" name="display" onBlur="doEcho(this.form)" value="0" class="textfield" size="2" disabled>
</form>
</body>
 
Okay and what are the results YOU are getting, I can easily find what I get but it's your results that count [or not] (pun intended)

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
thanks Chris, i wrote my own answer, Getting the results i need , :)

But ? have you ever Stored paths of PDF Files into a MySQL database "not the Files themselves >? any good links to that

or any examples you could put forward would be great..

 
have you ever Stored paths of PDF Files into a MySQL database "not the Files themselves >?

Yeah many times, it is only a simple fixed or variable width text field [CHAR(255) or VARCHAR(255) [ Preferred ] needed and an UPDATE or INSERT query.

However, it can't be done with javascript, (this being the js forum)

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top