Jump to content

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


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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...