Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-21-2012, 04:03 AM   PM User | #1
Britney90
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Britney90 is an unknown quantity at this point
Ajax php code working in mozilla not in IE

Hello!
I'm using one ajax code to list a set of text boxes based on the selection from a drop down list boxes. It is working in mozilla not working in IE. i am pasting the HTML and AJAX and PHP in here. pls tell me a solution wer im wrong immediately... pls

AJAX:

function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}

return xmlhttp;
}


function getform(formid) {

var strURL="findform.php?form="+formid;
var req = getXMLHTTP();

if (req) {

req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('formdiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}

PHP:

<?

$formt=$_GET['form'];

if($formt=="1")
{
echo '<tr><td class="bot">Name of 1st Kid</td><td>:</td><td><input type="text" name="kidn1" style="width:200px" /></td></tr>
<tr><td class="bot">Age of 1st Kid</td><td>:</td><td><input type="text" name="kida1" style="width:200px" /></td></tr>';
}
else if($formt=="2")
{
echo '<tr><td class="bot">Name of 1st Kid</td><td>:</td><td><input type="text" name="kidn1" style="width:200px" /></td></tr>
<tr><td class="bot">Age of 1st Kid</td><td>:</td><td><input type="text" name="kida1" style="width:200px" /></td></tr>
<tr><td class="bot">Name of 2nd Kid</td><td>:</td><td><input type="text" name="kidn2" style="width:200px" /></td></tr>
<tr><td class="bot">Age of 2nd Kid</td><td>:</td><td><input type="text" name="kida2" style="width:200px" /></td></tr>';
}
else if($formt=="3")
{
echo '<tr><td class="bot">Name of 1st Kid</td><td>:</td><td><input type="text" name="kidn1" style="width:200px" /></td></tr>
<tr><td class="bot">Age of 1st Kid</td><td>:</td><td><input type="text" name="kida1" style="width:200px" /></td></tr>
<tr><td class="bot">Name of 2nd Kid</td><td>:</td><td><input type="text" name="kidn2" style="width:200px" /></td></tr>
<tr><td class="bot">Age of 2nd Kid</td><td>:</td><td><input type="text" name="kida2" style="width:200px" /></td></tr>
<tr><td class="bot">Name of 3rd Kid</td><td>:</td><td><input type="text" name="kidn3" style="width:200px" /></td></tr>
<tr><td class="bot">Age of 3rd Kid</td><td>:</td><td><input type="text" name="kida3" style="width:200px" /></td></tr>';
}
?>

HTML

<tr><td class="bot">No of Kids</td><td>:</td><td><select name="noofkids" style="width:200px" onchange="getform(this.value)" id="frmid">
<option value="no">No of Kids</option><option value="1">1</option><option value="2">2</option><option value="3">3</option></select>
</td></tr>
<tr><td colspan="3"><table id="formdiv" style="border: 1px dotted green"></table></td></tr>
Britney90 is offline   Reply With Quote
Old 09-21-2012, 09:01 AM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 530 Times in 524 Posts
devnull69 will become famous soon enough
IE is having a lot of trouble with setting the innerHTML of a table element. Maybe you can use a DIV instead? Otherwise you should try to include the <table> tag itself into the PHP response so that you'll add the whole table.
devnull69 is offline   Reply With Quote
Old 09-25-2012, 03:14 PM   PM User | #3
Britney90
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Britney90 is an unknown quantity at this point
Quote:
Originally Posted by devnull69 View Post
IE is having a lot of trouble with setting the innerHTML of a table element. Maybe you can use a DIV instead? Otherwise you should try to include the <table> tag itself into the PHP response so that you'll add the whole table.
Thank you for sharing a very detailed, I will try it.
Britney90 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:54 AM.


Advertisement
Log in to turn off these ads.