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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox updated by another textbox data 1

Status
Not open for further replies.

Scope72

Programmer
Aug 17, 2011
1
US
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.
 
What I need to do, is update the txtPrice box without submitting the page/form.

Then the PHP forum s not the place to ask this. If you need to perform calculations on the fly, I suggest Javascript, which it seems is what you are doing, however, the name of your function is wrong, as Javascript is case sensitive. GetElementById is different to [red]g[/red]etElementById. Also your function takes 2 parameters yet you pass none.

If you need specific help with JS I suggest posting in forum216 for more detailed answers.

As it stands the question is off topic for this forum.




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top