Jump to content

Need to data entered in one form field to immediately show altered result in another


tartnboy

Recommended Posts

I have an eForm written in classic ASP. The mailer, which is written in vbscript does the multiplication just fine, and sends the result of the total amount entered in the first text box as a dollar value, and the result of that value multiplied by 0.25 in the email sent to the customer. The problem is, the client wants the result to show up in a separate field immediately on the form after the amount is entered in the first text box. It won't do it with VBScript because that is server side code and can't update the information until I hit the submit button. I have looked at several examples of AJAX and JavaScript throughout the internet in an attempt to find something that will do what I need. I think that I would need to use the getelementbyid function, but not sure. Can anyone suggest the proper way to do this?Thanks for any direction anyone can provide.Sincerely,BillM

Link to comment
Share on other sites

You can use document.getElementById to help get the value from the one field and put a value in the other field. If it's just simple multiplication there's no reason to use ajax, you can just do the math in Javascript. You can use the onkeyup event on the first field to trigger the function to run.

Link to comment
Share on other sites

I figured that was the case, but that is one of those elements of JavaScript I haven't had to use before. Could you suggest sample code of usage of that method? Again, when an amount is entered in textbox1, I want to multiply that value entered by 0.25 and show the result in textbox2, displayed as a monitary value, with the standard 2 decimal places.Thanks in advance for your assistance. Sincerely,BillM

Link to comment
Share on other sites

well, have you looked up document.getElementById? That would be a start. It's very easy to use.Then it's just a matter of when you want the action (multiplication and text setting) to take place. i.e., after the input loses focus, when they click a button, etc.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...