Jump to content


Photo

onchange no longer works?


  • Please log in to reply
5 replies to this topic

#1 jasonc

jasonc
  • Members
  • PipPipPip
  • Advanced Member
  • 841 posts

Posted 19 March 2006 - 08:06 PM

below is part of the code that does not work, i have placed it into a new file and tried to get it to work

when one option is selected the other clears back to '0' and vise versa.

it did work at one point but something is wrong now can not see what it is myself

can anyone spot what is missing or wrong?

thanks




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form" method="post" action="">
<select onchange=form.banana.value=0; form.bananaLB.value=0; name=bananaKG>
<option selected value=0>0kg</option><option value=1>1kg</option><option value=2>2kg</option>
<option value=3>3kg</option><option value=4>4kg</option><option value=5>5kg</option>
<option value=6>6kg</option><option value=7>7kg</option><option value=8>8kg</option>
<option value=9>9kg</option><option value=10>10kg</option></select>
<br>
<select onchange=form.banana.value=0; form.bananaKG.value=0; name=bananaLB>
<option selected value=0>0lb</option><option value=1>1lb</option><option value=2>2lb</option>
<option value=3>3lb</option><option value=4>4lb</option><option value=5>5lb</option>
<option value=6>6lb</option><option value=7>7lb</option><option value=8>8lb</option>
<option value=9>9lb</option><option value=10>10lb</option></select>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 19 March 2006 - 08:29 PM

What are you trying to do? Cause you've programmed it to set to zero on each change:

onchange=form.banana.value=0; form.bananaLB.value=0;


#3 jasonc

jasonc
  • Members
  • PipPipPip
  • Advanced Member
  • 841 posts

Posted 19 March 2006 - 08:39 PM

[!--quoteo(post=356483:date=Mar 19 2006, 08:29 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 19 2006, 08:29 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
What are you trying to do? Cause you've programmed it to set to zero on each change:

onchange=form.banana.value=0; form.bananaLB.value=0;
[/quote]


if option one selected option two is set to '0' if option two is selected option one is set to '0'

option one is bananaKG option two is bananaLB

ignor the 'banana.value=0' this is for a third option if needed.

has no effect at the moment.

i select one and it should clear the other but it doesn't it keeps it value.



#4 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 19 March 2006 - 08:51 PM

<body>
<form name="form" method="post" name="banana" action="">
<select onchange="form.bananaLB.selectedIndex=0;" name=bananaKG>
<option selected value=0>0kg</option><option value=1>1kg</option><option value=2>2kg</option>
<option value=3>3kg</option><option value=4>4kg</option><option value=5>5kg</option>
<option value=6>6kg</option><option value=7>7kg</option><option value=8>8kg</option>
<option value=9>9kg</option><option value=10>10kg</option></select>
<br>
<select onchange="form.bananaKG.selectedIndex=0;" name=bananaLB>
<option selected value=0>0lb</option><option value=1>1lb</option><option value=2>2lb</option>
<option value=3>3lb</option><option value=4>4lb</option><option value=5>5lb</option>
<option value=6>6lb</option><option value=7>7lb</option><option value=8>8lb</option>
<option value=9>9lb</option><option value=10>10lb</option></select>
<input type="submit" name="Submit" value="Submit">
</form>
</body>


#5 jasonc

jasonc
  • Members
  • PipPipPip
  • Advanced Member
  • 841 posts

Posted 19 March 2006 - 10:17 PM

below is the code that is created by the php file.

<form method="POST" action="orderpage.php">
<input name="submit" type="submit" value="Log Out">

<table border="3">
<tr width=\"100%\">
<td width="204" align="center"><img border=0 src="fruit and veg images/banana.jpg"><br>
<table width=200 border=0>
<tr>
<td><div align="center">banana</div></td>
</tr>
</table>
<br>
1.00p kg<br>
(0.45p lb *)<br>
Required Weight in kgs
<select onchange="form.banana.value=0; form.bananaLB.value=0;" name=bananaKG>
<option selected value=0>0kg</option>
<option value=1>1kg</option>
<option value=2>2kg</option>
<option value=3>3kg</option>
<option value=4>4kg</option>
<option value=5>5kg</option>
<option value=6>6kg</option>
<option value=7>7kg</option>
<option value=8>8kg</option>
<option value=9>9kg</option>
<option value=10>10kg</option>
</select> <br>
Required Weight in lbs
<select onchange="form.banana.value=0; form.bananaKG.value=0;" name=bananaLB>
<option selected value=0>0lb</option>
<option value=1>1lb</option>
<option value=2>2lb</option>
<option value=3>3lb</option>
<option value=4>4lb</option>
<option value=5>5lb</option>
<option value=6>6lb</option>
<option value=7>7lb</option>
<option value=8>8lb</option>
<option value=9>9lb</option>
<option value=10>10lb</option>
</select> </td>
</tr>
</table>
<p><input type="submit" value="Preview Order" name="submit"><input type="submit" value="Reset" name="submit"></p></form>note about buying by LB's and if buying by item when it is sold by weight it is going to be around that weight and should not be sold at the stated price until it is weight correctly in KG.

#6 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 March 2006 - 12:04 AM

If you look at your js errors, it says that form.banana has no properties...which means it doesn't exist. Remove that part of your code and it will work correctly.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users