technotool
06-09-2008, 03:24 AM
Hi -
I am trying to Populate(onClick) a textarea with checked items from a selection of radiobuttons and checkboxes. The enduser will make necessary selections and then click populate to fill the textarea with selected items. here is what I have thusfar.
In a div container id="pe_exam", checkboxes and radiobuttons are ordered by the id= ' "pe_item"+n ' as below however when I click populate noting is being populated. any assistance would be greatly appreciated. technotool
<script language="Javascript" type="text/javascript">
function populateTextArea(){
var target = document.getElementById("targetarea")
for(var i=0; i < 1000; i++){
if (document.getElementByTagName("pe_exam").getElementById("pe_item"+i).checked == true){
target.value = target.value + " " + document.getElementByTagName("pe_exam").getElementById("pe_item"+i).value
} else {continue;}
}
}
</script>
</head>
<body>
<textarea id="targetarea" cols="100" rows="5"></textarea>
<br><b>Physical Exam:</b><br>
<form name="form_pe" method="" action="">
<a href="#" onClick="populateTextArea();">Populate</a>
General<br>
<div id="pe_exam">
<input type="radio" name="pe_gen1" id="pe_item2" value="alert and oriented x 3">A & O x3 <br>
<input type="radio" name="pe_gen2" id="pe_item4" value="No apparent distress">NAD
<input type="radio" name="pe_gen2" id="pe_item6" value="Obvious distress">Obvious distress<br>
<input type="radio" name="pe_gen3" id="pe_item8" value="normal respiation">Normal Respiration
<input type="radio" name="pe_gen3" id="pe_item10" value="Labored Respiration">Labored Respiration <br>
<input type="radio" name="pe_gen4" id="pe_item12" value="normal mood">Normal mood
<input type="radio" name="pe_gen4" id="pe_item14" value="Depressed Mood">Depressed Mood<br>
I am trying to Populate(onClick) a textarea with checked items from a selection of radiobuttons and checkboxes. The enduser will make necessary selections and then click populate to fill the textarea with selected items. here is what I have thusfar.
In a div container id="pe_exam", checkboxes and radiobuttons are ordered by the id= ' "pe_item"+n ' as below however when I click populate noting is being populated. any assistance would be greatly appreciated. technotool
<script language="Javascript" type="text/javascript">
function populateTextArea(){
var target = document.getElementById("targetarea")
for(var i=0; i < 1000; i++){
if (document.getElementByTagName("pe_exam").getElementById("pe_item"+i).checked == true){
target.value = target.value + " " + document.getElementByTagName("pe_exam").getElementById("pe_item"+i).value
} else {continue;}
}
}
</script>
</head>
<body>
<textarea id="targetarea" cols="100" rows="5"></textarea>
<br><b>Physical Exam:</b><br>
<form name="form_pe" method="" action="">
<a href="#" onClick="populateTextArea();">Populate</a>
General<br>
<div id="pe_exam">
<input type="radio" name="pe_gen1" id="pe_item2" value="alert and oriented x 3">A & O x3 <br>
<input type="radio" name="pe_gen2" id="pe_item4" value="No apparent distress">NAD
<input type="radio" name="pe_gen2" id="pe_item6" value="Obvious distress">Obvious distress<br>
<input type="radio" name="pe_gen3" id="pe_item8" value="normal respiation">Normal Respiration
<input type="radio" name="pe_gen3" id="pe_item10" value="Labored Respiration">Labored Respiration <br>
<input type="radio" name="pe_gen4" id="pe_item12" value="normal mood">Normal mood
<input type="radio" name="pe_gen4" id="pe_item14" value="Depressed Mood">Depressed Mood<br>