jasonc Posted March 19, 2006 Share Posted March 19, 2006 below is part of the code that does not work, i have placed it into a new file and tried to get it to workwhen 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 myselfcan 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> Quote Link to comment https://forums.phpfreaks.com/topic/5309-onchange-no-longer-works/ Share on other sites More sharing options...
hitman6003 Posted March 19, 2006 Share Posted March 19, 2006 What are you trying to do? Cause you've programmed it to set to zero on each change:[code]onchange=form.banana.value=0; form.bananaLB.value=0;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5309-onchange-no-longer-works/#findComment-18872 Share on other sites More sharing options...
jasonc Posted March 19, 2006 Author Share Posted March 19, 2006 [!--quoteo(post=356483:date=Mar 19 2006, 08:29 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 19 2006, 08:29 PM) [snapback]356483[/snapback][/div][div class=\'quotemain\'][!--quotec--]What are you trying to do? Cause you've programmed it to set to zero on each change:[code]onchange=form.banana.value=0; form.bananaLB.value=0;[/code][/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 bananaLBignor 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. Quote Link to comment https://forums.phpfreaks.com/topic/5309-onchange-no-longer-works/#findComment-18880 Share on other sites More sharing options...
hitman6003 Posted March 19, 2006 Share Posted March 19, 2006 [code]<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>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5309-onchange-no-longer-works/#findComment-18884 Share on other sites More sharing options...
jasonc Posted March 19, 2006 Author Share Posted March 19, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/5309-onchange-no-longer-works/#findComment-18902 Share on other sites More sharing options...
hitman6003 Posted March 20, 2006 Share Posted March 20, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/5309-onchange-no-longer-works/#findComment-18916 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.