r-it Posted December 13, 2006 Share Posted December 13, 2006 can anyone help me with this, please hav a look at the image in the link below to view what i'm trying to do. i'm doing this webapp in php, and this is what it should do: a person selects a quantity and without refreshing the page, and gives the total on the totals field. so from the dropdown, when they select a different quantity, 3 for example, it must multiply 3 by the price and give the total for every change, like if they select a quantity and then they choose to select a new one, the dropdown must handle this. I initially wanted a list box,like you have in vb so that a eron can just click the down or up arrow to select the quantity but i dunno how this is done in plain html, my editor doesnt have that. please, any help is welcome, urls whatever http://img145.imageshack.us/my.php?image=itemswf0.jpg Quote Link to comment Share on other sites More sharing options...
fenway Posted December 13, 2006 Share Posted December 13, 2006 Maybe I misunderstood... you simply want to update the total with price*quantity? Quote Link to comment Share on other sites More sharing options...
r-it Posted December 27, 2006 Author Share Posted December 27, 2006 yeah thats what i wanna do, but with javascript, so it happens instantly and without reloading the page. Quote Link to comment Share on other sites More sharing options...
Submerged Posted December 27, 2006 Share Posted December 27, 2006 Hmmm... I would have an onChange event in the drop down box, that would activate a function that would then fill teh other values (price, quantity) with the right values based on the new selection. I'm not fluent enough to do that off the top of ny head, but that would work :P Quote Link to comment Share on other sites More sharing options...
r-it Posted December 28, 2006 Author Share Posted December 28, 2006 thanx 4 ur input dude, bt i hv no idea where i would start Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 It's sloppy, but it should get you started.[code]<style type="text/css"> img { border-style:none; }</style><script type="text/javascript">function readd(i) { f=document.forms['myform']; f.elements['total'+i].value = f.elements['price'+i].value * f.elements['quantity'+i].value;}function upme(i) { f=document.forms['myform'].elements['quantity'+i]; f.value = (f.value * 1) + 1; readd(i);}function downme(i) { f=document.forms['myform'].elements['quantity'+i]; if(f.value>0) { f.value = (f.value * 1) - 1; readd(i); }}</script></head><body><form name="myform" action="checkboxes.asp" method="post"><input type="text" name="nailgun" value="nailgun" readonly="readonly" /><input type="text" value="199" name="price1" readonly="readonly" /><input type="text" value="0" name="quantity1" readonly="readonly" /><a href="#" onClick="upme(1); return false;"><img src="up.gif" alt="up" /></a><a href="#" onClick="downme(1); return false;"><img src="down.gif" alt="down" /></a><input type="text" name="total1" value="0" readonly="readonly" /></form></body>[/code] Quote Link to comment 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.