Populating a text box with a value from another form field

Posted on 2011-10-12
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

    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"] + "%";
    LVL 2

    Assisted Solution


    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
    Both of these methods produced the results I was looking for.  Thank you very much for saving me from needing another Aleve.  :)

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
    This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
    In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now