Jump to content

onClick event not working


technotool

Recommended Posts

hi,
I seem to be missing something. the onClick event ("Normals") is doing NOTHING.  I am trying to set certain radio buttons to checked.  Any help would be greatly appreciated. 
technotool 
FireFox 2.0.0.14

<html>
<head>
<script language="Javascript" type="text/javascript">
normalValues(){
var norm_ao = document.getElementById("pe_gen1");
var norm_nr = document.getElementByID("pe_gen3");
norm_ao.checked = true;
norm_nr.checked = true;  
}
</script>
</head>
<body>
<br>
<b>Physical Exam:</b><br>
<form id="form_pe" method="" action="">
<a href="#" onClick="normalValues();">Normals</a> 
General<br>
<input type="radio" name="pe_gen1" id="pe_gen1" value="alert and oriented x 3">A & O x3  <br>
<input type="radio" name="pe_gen2" value="No apparent distress">NAD
<input type="radio" name="pe_gen2" value="Obvious distress">Obvious distress<br>                 
<input type="radio" name="pe_gen3" id="pe_gen3" value="normal respiation">Normal Respiration 
<input type="radio" name="pe_gen3" value="Labored Respiration">Labored Respiration <br>
<input type="radio" name="pe_gen4" value="normal mood">Normal mood 
<input type="radio" name="pe_gen4" value="Depressed Mood">Depressed Mood<br>
<button type="submit" value="submit">submit</button>
<button type="reset" value="reset">reset </button>
</form>
</body>
</html>

 

Link to comment
https://forums.phpfreaks.com/topic/109270-onclick-event-not-working/
Share on other sites

A couple of things here.

 

normalValues is a function so need to be declared as such and document.getElementByID should be document.getElementById.

 

function normalValues(){

var norm_ao = document.getElementById("pe_gen1");

var norm_nr = document.getElementById("pe_gen3");

norm_ao.checked = true;

norm_nr.checked = true; 

}

 

 

 

 

 

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.