954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Value passed in IE but not in firefox and opera

hi guyz

im new to HTML and CSS and i would to clarify the following doubt.


i have 2 pages
>index.php
>config.php

the index.php has a select box named "adamage", when i select the select box "atype" above, its supposed to change through AJAX and retrieve values (from a MySQL DB) for adamage according to atype

for eg. atype-art
adamage-frame, painting

atype-building
adamage-wall,door


The problem is that the AJAX works fine in all browsers, but the values cant get passed, also i cant get the selected value to be passed. :(

here is the Ajax code for config.php

<td>Area of damage :
<select name="adamage" style="width:205px">
<option >select damage type</option>
<? while($row=mysql_fetch_array($result)){ ?>
<option value>
<?=$row['adamage']?>
</option>
<? } ?>
</select></td>

which would overwrite index.php adamage

the Ajax retrieval code in the index.php are listed below <script>
function getdamage(strURL) {

var req = getXMLHTTP();

if (req) {

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

}
</script>


and.... <td>
<div class="mainleft">Article type: <select name="atype" onchange="getdamage('config.php?atype='+this.value)" style="width:205px">
<option value="">select article type</option>
<option value="1">Art</option>
<option value="2">Buildings</option>
</select></div>
</td>

<tr><td>&nbsp;</td></tr>


<td><div class="mainleft">
<div id="damagediv">
Area of damage : <select name="adamage" style="width:205px">
<option value="">select damage type</option>
</div></div>
</td>

xeracon
Newbie Poster
1 post since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

IE uses the DOM document object model so getelementbyid() only works in IE
mozilla opera safari use a diferent model
so we can

(document.getElementById) ? dom = true : dom = false; //check for IE dom model (once)
 if (dom) {	document.getElementById('damagediv').innerHTML=req.responseText; } //IE
 else {document.getElementById('damagediv').value=req.responseText;} } //mozilla opera
/* but
document.layers['damagediv'].value=req.responseText; 
also works in mozilla implementations */

// everywhere through the code
if(dom) {response ie}
else {response mozilla}

works most of the time
mozilla.org for a mozilla dom reference

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You