Populating a text box with a value from another form field

Posted on 2011-10-12
Medium Priority
Last Modified: 2012-06-21
You will have to look at the attached html file to see what I am asking.

I am trying to modify the attached HTML document so that the calculated value that will appear in  the field labeled "Framingham Cardiac Risk" will be appended in the text box at the bottom at the end.  So, if a calculated value is 8.5 in the Framingham Cardiac Risk box, the text box at the bottom will update to have a line that reads .L:FRA%:8.5

Is this possible?  Bear in mind that the needed values to perform the calculation are imported from an electronic medical record and the Framingham Cardiac Risk field will have a calculated value that may change if any other fields are manually changed by the user.  I just want the value to append as I described above.

Thanks for any insight.
Question by:Steve Bantz
LVL 10

Accepted Solution

Pramod Kumar earned 800 total points
ID: 36960097
Do below changes:

1) assign and ID to message area as (id="msg")
<textarea name="msg" rows="3" cols="63" id="msg">

2) add below line In function updateResults()
      document.getElementById("msg").value = ".L: FRA%: "+cvrPt["hchd"] + "%";

Assisted Solution

kamalranjan earned 200 total points
ID: 36960649

You can achieve the same by any of the following2 approaches:

1) Assign the id as msg to the textarea field and add the following line in your UpdateResults() function.

 document.getElementById("msg").value = ".L: FRA%:" + document.getElementById("ptchd2").value;

2) Place the textarea also in a form and assign the nameand id as say "frmOutput" and you can access that textarea field using document.frmOutput.msg.value so the line in javascript to update the final value will be like:

 document.frmOutput.msg.value = ".L: FRA%:" + document.getElementById("ptchd2").value;


Author Closing Comment

by:Steve Bantz
ID: 36962232
Both of these methods produced the results I was looking for.  Thank you very much for saving me from needing another Aleve.  :)

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question