Hi,
I am creating dynamic list in the server through php and insert it using ajax.
for ajax I using the following statement:
document.getEle mentById(list_n ame_id).innerHT ML=xmlHttp.resp onseText ;
until now everything is OK the list is builds correctly. but when I use the
document.getEle mentById(call_l ist_id).options .value I got an error saing "value is null or it is not an object" It seems that object list ID is null. Although when I was created the list I added a statement to the select "id=xxx".
Any suggestions how to solve this issue.
Here is my code:
Thanks
Ronen
I am creating dynamic list in the server through php and insert it using ajax.
for ajax I using the following statement:
document.getEle mentById(list_n ame_id).innerHT ML=xmlHttp.resp onseText ;
until now everything is OK the list is builds correctly. but when I use the
document.getEle mentById(call_l ist_id).options .value I got an error saing "value is null or it is not an object" It seems that object list ID is null. Although when I was created the list I added a statement to the select "id=xxx".
Any suggestions how to solve this issue.
Here is my code:
Code:
<html> <head> <title></title> <script language="javascript" type="text/javascript"> var last_model_category_selected="none"; var last_manufacture_selected="none"; var last_model_type_selected="none"; var last_model_name_selected="none"; var url_base="http://192.168.2.6:8080/src/autocomplete/create_generic_listbox.php?"; function buildList(call_list_id,list_name_id) { //call_list_id - The div that calls the function //list_name_id - the id of the list to be created // // Remember the value select in category list var url; if (call_list_id == "modelCategory" ) { last_model_category_selected=document.getElementById(call_list_id).options.value ; url=url_base+"isEmpty=FALSE&list_type=manufacture&last_selected="+last_manufacture_selected+"& list_dependency_1="+last_model_category_selected+"&list_dependency_2=''&list_dependency_3=''" ; // alert(last_model_category_selected); } else if (call_list_id == "manufacture") { //alert(call_list_id); last_manufacture_selected=document.getElementById(call_list_id).options.value ; url=url_base+"isEmpty=FALSE&list_type=model_type&last_selected="+last_model_type_selected+"& list_dependency_1="+last_model_category_selected+"&list_dependency_2="+last_manufacture_selected+"&list_dependency_3=''" ; } else if (call_list_id == "modelType") { last_model_type_selected=document.getElementById(call_list_id).options.value ; url=url_base+"isEmpty=FALSE&list_type=model_type&last_selected="+last_model_type_selected+"& list_dependency_1="+last_model_category_selected+"&list_dependency_2="+last_manufacture_selected+"&list_dependency_3="+last_model_type_selected ; } else { return FALSE; } // Perform Ajax request xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return FALSE; } xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4 && xmlHttp.status==200) { document.getElementById(list_name_id).innerHTML=xmlHttp.responseText ; } }; xmlHttp.open("GET", url); xmlHttp.send(null); } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } </script> </head> <body oninit=buildLists();> <form id="productSelector"> <div id="modelCategoryDiv" > </div> <select name="modelCategory" id="modelCategory" style="width:130" onchange="buildList('modelCategory','manufacture')"> <option value="none" selected >none</option> <option value="x" >x</option> <option value="y" >y</option> <option value="z">z</option> <option value="t">t</option> </select> <div id="manufacture"> </div> <div id="modelType"> </div> <div id="modelName"> </div> </form> </body> </html>
Thanks
Ronen
Comment