Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]Jason Tan Boon Teck[/eluser]
I am not sure which is the cause of the failure - CI, XHTML, Javascript, etc.?
What the form does is to trigger a reload of the page whenever a drop down selection is changed. This will retrieved a different set of selections in the second drop down (cascading menu). I gave removed a third drop down, to reduce complexity of testing.
Right now, onChange doesn't seem to work. [removed]() also doesn't seem to display, but alert() does. I have deliberately misspelled some terms to prevent the forum app from stripping away the codes. Can anyone spot my error? Thanks.
View file:
Code: <?php
echo "\n<body class='html'>";
echo "<sscript language='javascript' type='text/javascript'>";
echo "document. write('JS in body');";
echo "</sscript>";
echo form_open('emr/edit_diagnosis/'.$patient_id);
echo "\n<table class='frame' width='100%' align='center'>";
echo "<tr>";
echo "\n<td width='25%'><b>Diagnosis Chapter <font color='red'>*</font></b></td>";
echo "<td colspan='2' class='red'>";
echo "\n<select name='diagnosisChapter' class='normal' oonChange='jaavascript:selectDiagnosisCategory()'>";
echo "\n<option label='' value='0'>Choice 0</option>";
echo "\n<option label='' value='K00-K93 Diseases of the digestive system'>Choice 1</option>";
echo "\n<option label='' value='C00-D48 Neoplasms'>Choice 2</option>";
echo "</select>";
echo "</td>";
echo "</tr>";
echo "\n<tr>";
echo "\n<td width='25%'><b>Diagnosis Category (ICD-10)<font color='red'>*</font></b></td>";
echo "\n<td colspan='2' class='red'>";
echo "\n<select name='diagnosisCategory' class='normal' oonChange='jaavascript:selectDiagnosis()'>";
echo "\n<option value='' >Please select one</option>";
foreach($dcode1_list as $dcode1)
{
echo "\n<option value='".$dcode1['dcode1_code']."' ";
echo ($diagnosisCategory==$dcode1['dcode1_code'] ? " selected='selected'" : " ");
echo ">".$dcode1['dcode1_code']." [".$dcode1['full_title']."]</option>";
} //foreach
echo "</select>";
echo "</td>";
echo "</tr>";
?>
</table>
<br />
<center>
<input class='button' type='submit' name='submit' value='Enter Diagnosis' />
</center>
</form>
<br />
<sscript language="javascript" type="text/javascript">
<![CDATA[
allert('Javascript is turned on!')
document .write('JS in body');
function selectDiagnosisCategory(){
document.form.status.value="Unfinished";
document.form.diagnosisCategory.selectedIndex = -1;
document.form.diagnosis.selectedIndex = -1;
document.form.diagnosis2.selectedIndex = -1;
document.form.submit.click();
}
function selectDiagnosis(){
document.form.status.value="Unfinished";
document.form.diagnosis.selectedIndex = -1;
document.form.diagnosis2.selectedIndex = -1;
document.form.submit.click();
}
function selectDiagnosis2()
{
document.form.status.value="Unfinished";
document.form.diagnosis2.selectedIndex = -1;
document.form.submit.click();
}
]]>
</sscript>
</body></html>
The
Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]Jason Tan Boon Teck[/eluser]
The output as xhtml is as follows:
Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="12082007010920071193889920_files/thirra_style.css" rel="stylesheet" type="text/css"/>
<title>Diagnosis</title>
</head>
<body class="html">[removed][removed]('JS in body');[removed]
<br/>diagnosisChapter <br/>diagnosisCategory<br/>diagnosis<br/>diagnosis2<br/><form action="http://192.168.0.18/thirra/index.php/emr/edit_diagnosis/12082007010920071193889920" method="post">
<table width="100%" align="center" class="frame"><tr>
<td width="25%"><b>Diagnosis Chapter <font color="red">*</font></b></td><td colspan="2" class="red">
<select name="diagnosisChapter" class="normal">
<option label="" value="0">Choice 0</option>
<option label="" value="K00-K93 Diseases of the digestive system">Choice 1</option>
<option label="" value="C00-D48 Neoplasms">Choice 2</option></select></td></tr>
<tr>
<td width="25%"><b>Diagnosis Category (ICD-10)<font color="red">*</font></b></td>
<td colspan="2" class="red">
<select name="diagnosisCategory" class="normal">
<option value="">Please select one</option></select></td></tr>
</table>
<br/>
<center>
<input type="submit" class="button" name="submit" value="Enter Diagnosis"/>
</center>
</form>
<br/>
[removed]
<![CDATA[
alert('Javascript is turned on!')
[removed]('JS in body');
function selectDiagnosisCategory(){
document.form.status.value="Unfinished";
document.form.diagnosisCategory.selectedIndex = -1;
document.form.diagnosis.selectedIndex = -1;
document.form.diagnosis2.selectedIndex = -1;
document.form.submit.click();
}
function selectDiagnosis(){
document.form.status.value="Unfinished";
document.form.diagnosis.selectedIndex = -1;
document.form.diagnosis2.selectedIndex = -1;
document.form.submit.click();
}
function selectDiagnosis2()
{
document.form.status.value="Unfinished";
document.form.diagnosis2.selectedIndex = -1;
document.form.submit.click();
}
]]>
[removed]
</body></html>
Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]Arun Kris[/eluser]
If the onchange event is not working in mozila then set an id atribute to the <select> element and try.
Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]geshan[/eluser]
use some jquery (http://jquery.com) or you might again have problem with IE.
Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]Jason Tan Boon Teck[/eluser]
[quote author="Arun Kris" date="1257263656"]If the onchange event is not working in mozila then set an id atribute to the <select> element and try. [/quote]
Could you please elaborate? I'm weak at Javascript and the above js snippets are not mine. Thanks.
Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]saidai jagan[/eluser]
<select name='diagnosisChapter' class='normal' oonChange='jaavascriptelectDiagnosisCategory()'>";
Change it to
<select name='diagnosisChapter' class='normal'>";
Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]LuckyFella73[/eluser]
Hi,
If you want your XHTML code to be valid you have to write
the event handler in lowercase letters.
Valid: "onchange"
NOT valid: "onChange"
I don't know if that could solve your problem but you could
try maybe.
Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]Arun Kris[/eluser]
ok tell you later
Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]Arun Kris[/eluser]
simply add the id attribute to the <select element>
Javascript onChange not working in xhtml - El Forum - 11-03-2009
[eluser]Jason Tan Boon Teck[/eluser]
[quote author="LuckyFella73" date="1257269059"]Hi,
If you want your XHTML code to be valid you have to write
the event handler in lowercase letters.
Valid: "onchange"
NOT valid: "onChange"
I don't know if that could solve your problem but you could
try maybe.[/quote]
I tried. That didn't help the script. :-(
|