Scope72 Posted August 17, 2011 Share Posted August 17, 2011 I have 2 textboxes (txtPrice, txtPercent). What I need to do, is update the txtPrice box without submitting the page/form. When the txtPercent is changed, I would like to call a function which would then take the txtPrice value and multiply it by txtPercent and add that back into the txtPrice. Then I need to update the txtPrice box without submitting the page. <td align="right"><?php print "Price" ?>:</td><td><input type="text" name="txtPrice" size="15" value="<?php print $txtPrice?>" /> <td align="right"><?php print "Percent" ?>:</td><td><input type="text" name="txtPercent" onChange="updatePrice()" size="15" value="<?php print $txtPercent?>" /> function updatePrice(txtPrice, txtPercent){ var newPrice; newPrice = (txtPrice * txtPercent) + txtPrice; document.GetElementById('txtPrice').value = newPrice } Thanks in advance for any help. Link to comment https://forums.phpfreaks.com/topic/245052-textbox-updated-by-another-textbox-data/ Share on other sites More sharing options...
xyph Posted August 17, 2011 Share Posted August 17, 2011 You want JavaScript for this. PHP is purely server-side. If you want server-side interaction, a client must submit information. Link to comment https://forums.phpfreaks.com/topic/245052-textbox-updated-by-another-textbox-data/#findComment-1258670 Share on other sites More sharing options...
Scope72 Posted August 17, 2011 Author Share Posted August 17, 2011 Would you know of any good examples that would show how to do this? Link to comment https://forums.phpfreaks.com/topic/245052-textbox-updated-by-another-textbox-data/#findComment-1258676 Share on other sites More sharing options...
xyph Posted August 17, 2011 Share Posted August 17, 2011 http://homepage.ntlworld.com/kayseycarvey/variables3.html Link to comment https://forums.phpfreaks.com/topic/245052-textbox-updated-by-another-textbox-data/#findComment-1258680 Share on other sites More sharing options...
Scope72 Posted August 17, 2011 Author Share Posted August 17, 2011 Thank you for your help. With the website and a little more digging I was able to get it to work. Link to comment https://forums.phpfreaks.com/topic/245052-textbox-updated-by-another-textbox-data/#findComment-1258709 Share on other sites More sharing options...
xyph Posted August 17, 2011 Share Posted August 17, 2011 Perfect, glad you could get this cleaned up on your own Link to comment https://forums.phpfreaks.com/topic/245052-textbox-updated-by-another-textbox-data/#findComment-1258711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.