473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do i make an "onChange" event to register in internet explorer?

5
Hi all, i am writing an ajax and php application for a sec ondary school, and i want the contents of one select list to be based on the values of the select list that appears before it. The issue is that the onChange event that fires the function that sends the ajax request to populate the second select list does not have any effect when i am using internet explorer. Please help me fix this.
I have enclosed my code below.
Tanx.
This is the form that accepts data
Expand|Select|Wrap|Line Numbers
  1. <?php session_start();?>
  2. <html>
  3. <head>
  4. <link rel="stylesheet" type="text/css" href="main2.css">
  5. <script type="text/javascript">
  6.  var request = false;
  7.    try {
  8.      request = new XMLHttpRequest();
  9.    } catch (e) {
  10.      try {
  11.        request = new ActiveXObject("Msxml2.XMLHTTP");
  12.      } catch (e2) {
  13.        try {
  14.          request = new ActiveXObject("Microsoft.XMLHTTP");
  15.        } catch (e3) {
  16.          request = false;
  17.        }  
  18.      }
  19.    }
  20.    if (!request)
  21.      alert("Sorry Your Browser Settings Do Not Permit You To Use This Application!");
  22.      var request2 = false;
  23.    try {
  24.      request2 = new XMLHttpRequest();
  25.    } catch (e) {
  26.      try {
  27.        request2 = new ActiveXObject("Msxml2.XMLHTTP");
  28.      } catch (e2) {
  29.        try {
  30.          request2 = new ActiveXObject("Microsoft.XMLHTTP");
  31.        } catch (e3) {
  32.          request = false;
  33.        }  
  34.      }
  35.    }
  36.    if (!request2)
  37.      alert("Sorry Your Browser Settings Do Not Permit You To Use This Application!");
  38. function get_number(){
  39. var i=document.getElementById("number").value;
  40. var class=document.getElementById("get_class").value;
  41. var form=document.getElementById("form").value;
  42. if (i=="")
  43. {alert("Please Supply A Valid Number");
  44. return;}
  45.    if(form==0){
  46.    alert("Please Select A Valid Form!!! ");
  47.    return;}
  48. else{ var url = "/demonstration/get_number.php?number=" + escape(i) + "&class=" +escape(class)+"&form=" +escape(form);
  49.      request2.open("GET", url, true);
  50.      request2.onreadystatechange = updatePage;
  51.      request2.send(null);}
  52.  
  53.    }
  54.       function updatePage(){
  55. if(request2.readyState==4){
  56. if(request2.status==200)
  57. {var response2=request2.responseText;
  58. if (request2.responseText=='')
  59. {alert("Sorry,An Error Ocurred.Please Try Again Later.!!");}
  60. else{
  61.  
  62. document.getElementById("feedback").innerHTML=response2;
  63.  
  64.  
  65. }
  66.  
  67. }
  68. else{
  69. alert("Status is " + request.status);}}}
  70. function getclass(){
  71. var i=document.getElementById("number").value;
  72. var form=document.getElementById("form").value;
  73.  
  74.    if(form==0){
  75.    alert("Please Select A Valid Form!!! ");}
  76.    else{
  77.    var url = "/demonstration/get_class.php?form=" + escape(form);
  78.      request.open("GET", url, true);
  79.      request.onreadystatechange = updateForm;
  80.      request.send(null);}}
  81.      function updateForm(){
  82. if(request.readyState==4){
  83. if(request.status==200)
  84. {var response=request.responseText.split("|");
  85. if (request.responseText=='')
  86. {alert("Sorry,An Error Ocurred.Please Try Again Later.!!");}
  87. else{
  88.  
  89. document.getElementById("get_class").innerHTML=response[0];
  90.  
  91.  
  92. }
  93.  
  94. }
  95. else{
  96. alert("Status is " + request.status);}}}
  97.  
  98.  
  99. </script>
  100. </head>
  101.  
  102. <body>
  103. <div class="container" align="center">
  104. <h2 align="center">Please Enter The Form,Class And Number Of Fresh Students You Want To Register Below</h2>
  105. <hr/>
  106. <?php 
  107. $user_id=$_SESSION['user_id'];
  108. include 'demo_connect.php';
  109.  
  110. $sql="select * from forms";
  111. $result=mysqli_query($link,$sql);
  112.  
  113. echo '
  114. <table><tr><td class=form align=right>Form:</td><td><select name="form" id=form onChange=getclass();>
  115. <option value=0>Select Form Here</option>';
  116. while ($r=mysqli_fetch_assoc($result))
  117. {$form=$r['form_name'];
  118.  
  119. echo "<option value="; echo $r['form_id'];echo ">$form\n";
  120. }
  121. echo'</select></td></tr>
  122. <tr><td class=form align=right>Class:</td><td id="class_feedback"><select id=get_class><option value=0>Get Class here</select></td></tr>
  123.  
  124. <tr><td class="form" align=right>Enter Desired Number Here:<td><input type="text" id="number"></td><td></td><td><input type="button" value="Submit Number" onClick="get_number();"></td></tr></table>
  125. <div id=feedback></div>
  126. <div id=submit_form></div>';
  127. ?>
  128.  
  129.  
  130. </div>
  131. </body>
  132. </html> 
AND THIS IS THE PHP FORM THAT RECEIVES THE AJAX REQUEST
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9. <?php
  10. include 'demo_connect.php';
  11. $form_id=mysqli_real_escape_string($link,$_GET['form']);
  12. $sql="select * from classes where form_id='$form_id' order by class_name";
  13. $result=mysqli_query($link,$sql);
  14. $a='
  15. <select name="class" id="class" onChange=trial();>
  16.  
  17.  
  18. ';
  19. while ($r=mysqli_fetch_assoc($result))
  20. {$class=$r['class_name'];
  21.  
  22. echo "<option value=";echo $r['class_id'];echo">$class\n</option>";
  23. }
  24. echo'</select></td></tr>';
  25. echo $a;
  26.  
  27. ?>
  28. </body>
  29. </html>
  30.  
Mar 30 '11 #1
0 1001

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark Durgee | last post by:
I have a "submit" button in a form that creates a record in my Filemaker database that works as it should. This is the HTML for it: <INPUT TYPE="SUBMIT" name="-New" VALUE="Add Record"> I...
2
by: @lias | last post by:
Hi all I have a webpage where I want the user to input filenames. To make this easier, I use a file input type so that the user can select files rather than typing in the filename, using the...
3
by: Norm via DotNetMonster.com | last post by:
I have an onchange event which fires when the content of an HTML textbox changes. My problem is that when I try to compare the content of this textbox with another HTML textbox using an if...
1
by: julian.tklim | last post by:
Hi, I've got an input box with popup calendar (date picker) all generated using javascipt. Once a date is selected from the datepicker window, the date value is populated back to the input...
6
by: jwarnock | last post by:
When a text field is terminated by a "tab" or change of focus, the browsers behave the same (IE, FireFox, Safari, Netscape). When the text field is terminated by a "return", then "onchange" is...
7
by: Tim Slattery | last post by:
I'm trying to handle the onChange event in an <input type="file"> element. In IE, there's no problem: the event fires when a file in the "open" box is doubleclicked, or the "Open" button in the box...
4
by: mbiasetti | last post by:
Hello, quick question (hopefully): I have a script that manipulates two "Select" elements. My onload calls a function that sets onchange for each "Select": ...
7
by: TriAdmin | last post by:
I am working with a system that allow me to add custom fields but I can not add OnChange() language to the custom fields. So I want to have a function in the header that recognizes when fieldx is...
19
by: maya | last post by:
hi, so what is "modern" javascript?? the same as "DOM-scripting"? i.e., editing content (or changing appearance of content) dynamically by massaging javascript objects, html elements, etc? ...
1
by: sandeep kumar shah | last post by:
Hi, We have used a file uploading HTML tag in an HTML page. We need to customize the text displayed on the Button (which is by default “Browse…” for internet explorer). Below is the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.