0

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>
2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by almostbob
1

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.