?
Solved

Drop Box menu selection changing dynamicly

Posted on 2006-11-15
61
Medium Priority
?
893 Views
Last Modified: 2012-08-14
i am using JSP - Servlet and oracel

I have two Drop Box menu in a form..

First one .. is populated from the Dtatabase ( The selection options come from database) .. for example all Item model I have in my store..

Second one .. is populated from the dtatabase .. according to the Selection of the first one .. for example all serial Number of such Item model have been selected in the first Drop menu Box.

so, I need second drop box to be changed according to the user selection in the first drop box menu ..?

How I can do it ? plz help =)
0
Comment
Question by:Sh_Rashed
  • 27
  • 26
  • 5
  • +1
61 Comments
 
LVL 10

Expert Comment

by:jaggernat
ID: 17948731
well, I had a similar requirement and I did it this way:

Write a java util class and in that util class, call the database and get the data. Store the data in xml format in a StringBuffer variable.

In your front-end you will have a jsp with javascript functions.  Load the StringBuffer (containing the xml data) in your javascript.
Now in your javascript use Xpath to traverse through the xml. So once the user changes the first drop-down,  write a onChange() (in first drop-down) which will call the function in javascript and that function will change the values in the  second drop-down accordingly.

0
 

Author Comment

by:Sh_Rashed
ID: 17953386
I have written those two methods in Controller Class..

public Vector getOptionSelection1 (){} // this methos return the selection options of drop box menu..

public Vector getOptionSelection2(String option){} // this method will return selection option in the second drop box.

so .. I will write a method ..ToXML (Vector v){}// return String in xml format..

Then How I can use javaScript (StringBuffer) .. I don't have any idea .. Help me  plz .. =)
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17953406
your stringbuffer would contain data in xml format like this

example:

<state>
  <region>
       <county>
        .....

       </county>
   </region>
</state>
and then use xpath in your javascrpt and navigate through the xml and fill the dropdowns

go though this
http://developer.mozilla.org/en/docs/Introduction_to_using_XPath_in_JavaScript
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Expert Comment

by:deeppra
ID: 17954410
for this u can use Ajax.. when the user select a particular item then using javascript the u send a request to a servlet in the server with the item the user selected as a parameter. Then the servlet will return all the items for the second list box. Then using the javascript u can add all the elements into the list.

This will work fine...

below link will detail u about Ajax,javascript and servlet
http://www-128.ibm.com/developerworks/library/j-ajax1/
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17955849
i agree with deeppra. ajax is another option.
0
 
LVL 14

Expert Comment

by:boonleng
ID: 17970680
I have just posted a sample code which you can refer to.
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_22052625.html

You probably can change it to directly open as text instead of xml.
Let me know if you have any query.
0
 

Author Comment

by:Sh_Rashed
ID: 17971707
Hi experts,

I like Ajax that is really what I need in this case. I have read the IBM article about Ajax ..I love it .. Thanks deeppra  =)

Now, I need to modify the javaScript in that article (http://www-128.ibm.com/developerworks/library/j-ajax1/) for my case .. I tried but it didn't work .. I don't have any experience with javaScript ..

in the form.html :

<p>Item Model : <select size="1" name="ItemModel"  onchange="getSN()">
      <option>Hp500</option>
      <option>Hp600</option>
      <option>Hp700</option>
      </select>

what I should pass with .. getSN()? <---?

This is my javaScript:


function getSN(itemModel) {

 var req = newXMLHttpRequest();

 req.onreadystatechange = getReadyStateHandler(req, updateSN);
 
 req.open("POST", "item.do", true);
 
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 
req.send("itemModel="+itemModel);}

---------------------------------------------------------------------------------------------

function updateSN(snXML) {
 
var root = sntXML.getElementsByTagName("root")[0];

 var generated = root.getAttribute("generated");
 
if (generated > lastUpdate) {
   
   lastUpdate = generated;
   
   var contents = document.getElementById("dropdown2");
   
   contents.innerHTML = "";

   var items = root.getElementsByTagName("Item");
   
for (var I = 0 ; I < items.length ; I++) {

     var itemsn = itemsn[I];
 
     var name = item.getElementsByTagName("SN")[0].firstChild.nodeValue;
     

     var listItem = document.createElement("li");
     listItem.appendChild(document.createTextNode(name));
     contents.appendChild(listItem);
   
}}}

----------------------------------------------------------------------

In the Servlet ..

request.getParameter("ItemModel") (<- which javaScript suppose to send to the Servlet) return null value..

-----------------------------------------------------------------------

The XML that will be send back to the XMLHttpResponse looks like the following:

<root>

<Item>
<SN> 122334 </SN>
<SN> 345666 </SN>
<Item>

<root>

----------------------------------------

I don't have any problem in the server side .. but in javaScript ?

Any Help ?!

0
 
LVL 14

Expert Comment

by:boonleng
ID: 17976622
You will pass in the selected value to the method getSN().
Example:
<select size="1" name="ItemModel"  onchange="getSN(this.options[this.selectedIndex])">
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17977197
i think u have only Nullpointer exception... the reason is u used itemModel in the javascript
req.send("itemModel="+itemModel);}

but in u r servlet u r using caps ItemModel this is the reason for NullPointer Exception

In the Servlet ..

request.getParameter("ItemModel") (<- which javaScript suppose to send to the Servlet) return null value..


So in u r servlet use itemModel
regards
Pradeep D
0
 

Author Comment

by:Sh_Rashed
ID: 17977529
Thank u boonleng and deepra ..

req.send("itemModel="+itemModel);} <-- I have changed it ..

Now . in the servlet . I print the request.getParameter("itemModel") .. as the following:

String itemModel = req.getParameter("itemModel");
       
System.out.println("---------- this is the model: ------- "+itemModel);

it prints : ---------- this is the model------------:  [object]

When I hard coded the value in the javaScript as the following:

req.send("itemModel= hp500");  .. it prints correctly in the Servlet.

I think the problem in the form.html:

<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex])" > <-- I think this line doen't pass the value to the java Script

any idea?
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17977543
the parameter in the getSN gives u the index of the selected item... and also change the <option> tag include the value attribute to it
like this
<option value="hp500">hp500</option>

in the javascript


instead of the this line
<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex])" > 

change it like this
<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex.value])" > 

so this directly passes the value of the selected item and that one will be added in the request
try this one and send me the reply
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17977550
sorry this the correct is this
<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex].value)" > 
0
 

Author Comment

by:Sh_Rashed
ID: 17977619
deeppra .. Thank u for ur time .. (F) ..

I changed the selection

<p>Item Model :<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex.value])" > 
      <option name ="itemModel" value="HP500">Hp500</option>
      <option name ="itemModel" value="HP600">Hp600</option>
      <option name ="itemModel" value="HP700">Hp700</option>
      </select></p>


and when I printed the request.getParameter("itemModel") ..

I got:

---------- this is the model:  undefined -----------------------


I think I will give up .. and jst put field instead of drop menu :D
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17977807
Item Model :<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex.value])" >

change like this

Item Model :<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex].value)" >
0
 

Author Comment

by:Sh_Rashed
ID: 17978486
^
Thank u .. that worked .. but .. I didn't get the reponse .. I don't know what is excatly the problem !

if I didn't receive XMLHttpResponse or not complete .. OR the problem in present the receivd data .. so how I can make sure that I have received the data?

This is the form.html:

<form name = "ItemsForm" method="POST" action="cart.do">
      
<p>Item Model :<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex].value)" >
 
      <option name ="itemModel" value="HP500">Hp500</option>
      <option name ="itemModel" value="HP600">Hp600</option>
      <option name ="itemModel" value="HP700">Hp700</option>
      </select></p>
       
      <p>Item Serial Number : <select size="1" name="ItemSN" id ="dropdown2"></select></p>
      
       
      
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>


-------------------------------------------


This is my JavaScript that will present the data... is there any error?!

function updateSN(snXML) {
 
var root = sntXML.getElementsByTagName("root")[0];

/* <-- ItemsForm is the name of the form in the form.html - and dropdown2 is the id of serial Number selection--> */

var contents = document.ItemsForm.getElementById("dropdown2");  

   
contents.innerHTML = "";

var items = root.getElementsByTagName("Item");
   

for (var I = 0 ; I < items.length ; I++) {

     var item = items[I];
 
     var name = item.getElementsByTagName("SN")[0].firstChild.nodeValue;
     

     var listItem = document.ItemsForm.createElement("option");
     
     listItem.appendChild(document.createTextNode(name));
     
     contents.appendChild(listItem);
   
}

 }

----------------------

The XML looks like:

<root>

<item>

<SN> 123 </SN>

</item>

<item>

<SN> 124 </SN>

</item>

 </root>

----------------------

This is the first time for me to write javaScript  =(

so ,, !? =)
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17978838
okay, in ur servlet u print the values and see whether its coming correctly or not
0
 

Author Comment

by:Sh_Rashed
ID: 17978876
in the Servlet it comes correctly ..

This is my doPost ..

  public void doPost(HttpServletRequest req, HttpServletResponse res) throws java.io.IOException {
       
       
        String itemModel = req.getParameter("itemModel");
       
        System.out.println("---------- this is the model---------: "+itemModel);
       
        Vector result = getAllSN(itemModel);
       
        String snXML = toXML(result);
       
        System.out.println("This is:-----------------------------------"+snXML);
       
        res.setContentType("text/xml");
       
        res.getWriter().write(snXML);
       
       
       
       
       
    }

and  it is print the value correctrly and create the xml correctly..
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17984888
then what output u r getting in the browser??
close ur outputstream like this
res.getWriter().write(snXML);
res.getWriter().close();

also see the output page source in the browser...
0
 

Author Comment

by:Sh_Rashed
ID: 17985243
In the Browser .. when I select from Item Model (First drop down) .. The second drop down menu not fill with the serial Number and I got error in the page.
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17985265
instead of creating XML message u send the itemModel with some delimiters like this
itemModel1#itemModel2#itemModel3
so in the javascript u split it and put it in the box
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17985274
check in the javascript callback function whether u r getting the XML response from the server
0
 

Author Comment

by:Sh_Rashed
ID: 17985372
function getReadyStateHandler(req, responseXmlHandler) {

  // Return an anonymous function that listens to the
  // XMLHttpRequest instance
  return function () {

    // If the request's status is "complete"
    if (req.readyState == 4) {
     
      // Check that a successful server response was received
      if (req.status == 200) {

        // Pass the XML payload of the response to the
        // handler function
        responseXmlHandler(req.responseXML);

      } else {

        // An HTTP problem has occurred
        alert("HTTP error: "+req.status);
      }
    }
  }
}


-----------------

I think there is error in extract xml javascript ?
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17985515
>>>I think there is error in extract xml javascript ?

so instead of using XML you send the itemModel in the response with out any XML code like this
itemModel1#itemModel2#itemModel3
0
 

Author Comment

by:Sh_Rashed
ID: 17985563
ummm . the String sns should be like this:

String sns = "123344#122334#1233445"; ?

Then how should I change the extract javaScript :

unction updateSN(snXML) {
 
var root = sntXML.getElementsByTagName("root")[0];

var contents = document.ItemsForm.getElementById("dropdown2");
   
contents.innerHTML = "";

var items = root.getElementsByTagName("Item");
   

for (var I = 0 ; I < items.length ; I++) {

     var item = items[I];
 
     var name = item.getElementsByTagName("SN")[0].firstChild.nodeValue;
     

     var listItem = document.ItemsForm.createElement("option");
     
     listItem.appendChild(document.createTextNode(name));
     
     contents.appendChild(listItem);
   
}

 }

?
0
 

Author Comment

by:Sh_Rashed
ID: 17985575
Strign sns = "12345#12233#1223" <-- This will be getting from the database according to the selection in the first drop box
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17985705
okay after getting the string in the javascript use some of the string functions to extract each item
for more information on string function in javascript check this
http://www.javascriptkit.com/javatutors/string2.shtml
http://richardbowles.tripod.com/javascript/section10/lesson10.htm

i think this will help u
0
 

Author Comment

by:Sh_Rashed
ID: 17986072
I wrote this javaScript and it didn't work  (Error on the page).. I think there is a syntax error ..

This is my javaScript .. check it plz

function writeSN(snXML){

var result = snXML;

array2 = result.split("#");

var contents = document.getElementById("dropdown2");
   contents.innerHTML = "";



for ( var I = 0 ; I < array2.length ; I++){

  var sn = array2[I]

  var listItem = document.ItemsForm.createElement("option");


 listItem.appendChild(document.createTextNode(sn));
     
contents.appendChild(li);



}
}
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17986080
what error u r getting ?? send me the line number and the details so that i can fix it
0
 

Author Comment

by:Sh_Rashed
ID: 17986081
This is the String that the servlet print ..

String sn = "66353528292#1111111111111111#77777777666666"
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17986092
use this code for updating the dropdown box
function writeSN(snXML){

var result = snXML;

array2 = result.split("#");

var dropdown = document.getElementById("dropdown2");

for ( var I = 0 ; I < array2.length ; I++){
   dropdown.options.add(new Option(array2[I],array2[I]));
}
}

see this for dropdown box
http://www.quirksmode.org/js/options.html
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17986096
if u have any errors then send me  the full code and the line number where u r getting error
0
 

Author Comment

by:Sh_Rashed
ID: 17986203
Errors on the Page .. :(((

I tried ur javaScript .. it didn't work .. I did some changes:

function writeSN(snXML){

var result = snXML;

array2 = result.split("#");



for ( var I = 0 ; I < array2.length ; I++){
   
document.forms['ItemsForm'].ItemSN.options[I] = new Option(array2[I],array2[I]);



}}


How I make sure that I have received response ?

This is my handler function .. that waiting for the response


function getReadyStateHandler(req, responseXmlHandler) {

  // Return an anonymous function that listens to the
  // XMLHttpRequest instance
  return function () {

    // If the request's status is "complete"
    if (req.readyState == 4) {
     
      // Check that a successful server response was received
      if (req.status == 200) {

        // Pass the XML payload of the response to the
        // handler function
        responseXmlHandler(req.responseXML);

      } else {

        // An HTTP problem has occurred
        alert("HTTP error: "+req.status);
      }
    }
  }
}

0
 
LVL 5

Expert Comment

by:deeppra
ID: 17986261
u show some alert or otherwise in the alert message give like this
alert(req.responseXML);
0
 

Author Comment

by:Sh_Rashed
ID: 17986313
When I added alert(req.responseXML); in the following sequence:

  if (req.status == 200) {

        // Pass the XML payload of the response to the
        // handler function
        alert(req.responseXML);
        responseXmlHandler(req.responseXML);

      }

it shows alert message : [object]

but when I added after:

  if (req.status == 200) {

        // Pass the XML payload of the response to the
        // handler function
        responseXmlHandler(req.responseXML);
       alert(req.responseXML);

      }

it doesn't show me that alert .. !!

0
 
LVL 14

Expert Comment

by:boonleng
ID: 17986556
Should be
    writeSN(req.responseXML)
instead of
    responseXmlHandler(req.responseXML);
0
 

Author Comment

by:Sh_Rashed
ID: 17986662
function getSN(itemModel) {

 var req = newXMLHttpRequest();

 req.onreadystatechange = getReadyStateHandler(req, writeSN); <---- This will be passed
 
 req.open("POST", "cart.do", true);
 
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 
req.send("itemModel="+itemModel);

}

function getReadyStateHandler(req, responseXmlHandler) {

  // Return an anonymous function that listens to the
  // XMLHttpRequest instance
  return function () {

    // If the request's status is "complete"
    if (req.readyState == 4) {
     
      // Check that a successful server response was received
      if (req.status == 200) {

        // Pass the XML payload of the response to the
        // handler function
       
         responseXmlHandler(req.responseXML);
       

      } else {

        // An HTTP problem has occurred
        alert("HTTP error: "+req.status);
      }
    }
  }
}


?
0
 
LVL 14

Expert Comment

by:boonleng
ID: 17992225
writeSN()  is a function, you only can pass object or value as paramater into the function.
Try change to

req.onreadystatechange = getReadyStateHandler(req);

getReadyStateHandler(req) {
         ....

        // Pass the XML payload of the response to the
        // handler function
       
         writeSN(req.responseXML);

         ....
}

0
 

Author Comment

by:Sh_Rashed
ID: 17993242
It doesn't work ..

Here is my code:


index.jsp :

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" language="javascript" src="ajax1.js"></script>
<script type="text/javascript" language="javascript" src="cart.js"></script>

</head>

<body>

<form name = "ItemsForm" method="POST" action="cart.do">
      
<p>Item Model :<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex].value)" >
 
      <option name ="itemModel" value="HP500">Hp500</option>
      <option name ="itemModel" value="HP600">Hp600</option>
      <option name ="itemModel" value="HP700">Hp700</option>
      </select></p>
       
      <p>Item Serial Number : <select size="1" name="ItemSN" id ="dropdown2"></select></p>
      
       
      
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

<ul id="cart-contents">

 
</ul>

</body>

</html>

--------------------------------

My ajax1 javaScript:

/*
 * Returns an new XMLHttpRequest object, or false if the browser
 * doesn't support it
 */
function newXMLHttpRequest() {

  var xmlreq = false;

  // Create XMLHttpRequest object in non-Microsoft browsers
  if (window.XMLHttpRequest) {
    xmlreq = new XMLHttpRequest();

  } else if (window.ActiveXObject) {

    try {
      // Try to create XMLHttpRequest in later versions
      // of Internet Explorer

      xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
     
    } catch (e1) {

      // Failed to create required ActiveXObject
     
      try {
        // Try version supported by older versions
        // of Internet Explorer
     
        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (e2) {

        // Unable to create an XMLHttpRequest by any means
        xmlreq = false;
      }
    }
  }

return xmlreq;
}


function getReadyStateHandler(req) {

  // Return an anonymous function that listens to the
  // XMLHttpRequest instance
  return function () {

    // If the request's status is "complete"
    if (req.readyState == 4) {
     
      // Check that a successful server response was received
      if (req.status == 200) {

        // Pass the XML payload of the response to the
        // handler function
       
         writeSN(req.responseXML);
       

      } else {

        // An HTTP problem has occurred
        alert("HTTP error: "+req.status);
      }
    }
  }
}


--------------------------------

My cart javaScript:

function getSN(itemModel) {

 var req = newXMLHttpRequest();

 req.onreadystatechange = getReadyStateHandler(req);
 
 req.open("POST", "cart.do", true);
 
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 
req.send("itemModel="+itemModel);

}


function writeSN(snXML){

var result = snXML;

array2 = result.split("#");

var dropdown = document.getElementById("dropdown2");

for ( var I = 0 ; I < array2.length ; I++){

dropdown.options.add(new Option(array2[I],array2[I]));

}

--------------------------------------------

My Servlet code:

public void doPost(HttpServletRequest req, HttpServletResponse res) throws java.io.IOException {
       
       
        String itemModel = req.getParameter("itemModel");
       
        System.out.println("---------- this is the model---------: "+itemModel);
       
        Vector result = getAllSN(itemModel);
       
        String snXML = toXML(result);
       
        System.out.println("This is:-----------------------------------"+snXML);
       
        res.setContentType("application/xml");
       
        res.getWriter().write(snXML);
       
        res.getWriter().close();
       
         System.out.println("------ the response----"+res.isCommitted());
       
       
       
       
       
       
    }

-------------------------------------

How I make sure that I have received my response? is there any system.print.out in javaScript ?..=)


0
 
LVL 14

Expert Comment

by:boonleng
ID: 17993485
try add in alert in javascript. Is there any javascript error show on browser?

function writeSN(snXML){
   alert(snXML);
   ...
}
0
 

Author Comment

by:Sh_Rashed
ID: 17993781
alert(SNXML) == gives me this message: [Object]

Is there any javascript error show on browser? <= show me in the status bar (Errors on page)
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17994059
in the servlet change the content type as text/html and also u change the browser setting of IE to enable script debugging. Follow these steps to change the setting
1) open IE
2) select tools->Internet Options
3) select Advance tab in the dialog box
4) see whether "Disable Script Debugging (Internet Explorer" and "Disable script        
     Debugging(Other)" is unchecked
5) and also check the below option "Display a notification about every script error"
6) click ok and open the page in IE

Then will get the error message and see the details and send me the error message

0
 

Author Comment

by:Sh_Rashed
ID: 17994173
it gives me this messgae:

object doesn't support this property or method
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17994186
in which line its giving the error and also send me those few line above and below that
0
 

Author Comment

by:Sh_Rashed
ID: 17994232
the eroor in line 22 :

function writeSN(snXML){

alert(snXML)

var result = snXML;

array2 = result.split("#"); //<----------------22( in this line)

var dropdown = document.getElementById("dropdown2");

for ( var I = 0 ; I < array2.length ; I++){

dropdown.options.add(new Option(array2[I],array2[I]));

}

}

and I got the following message whn I debug the error .. " Script does not support disassembly."

0
 

Author Comment

by:Sh_Rashed
ID: 17994317
when I run in the firefox , alert message is : null
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17994324
see what type of object is snXML i dont think its a string object its some other... just check that one

see this one writeSN(req.responseXML); what is this and what is responseXML
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17994333
uses some other functions on snXML object and see whether its working

substring()
charAt()
split () and join()
toUpperCase()
toLowerCase()
0
 

Author Comment

by:Sh_Rashed
ID: 17994399
first I declare the req as the following:
 
var req = newXMLHttpRequest();

then pass the response of the req (When it is completed) to writeSN(req.responseXML):

 req.onreadystatechange = getReadyStateHandler(req,writeSN);

f (req.status == 200) {

        writeSN(req.responseXML);
}


function writeSN(snxml){} // for extract the data

I have follow the listings in this link : http://www-128.ibm.com/developerworks/library/j-ajax1/
0
 

Author Comment

by:Sh_Rashed
ID: 17994591
it doen't work . I think it receive null response ?! :((
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17994736
instead of using req.reponseXML use req.responseText... since responseXML is not a String object its a Document object
so try this one

for reference see this link
http://www.brainjar.com/dhtml/ajax/
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17994742
0
 

Author Comment

by:Sh_Rashed
ID: 17994775
Thank u .. I will read them and try to know what is the problem .. =)
0
 
LVL 5

Accepted Solution

by:
deeppra earned 2000 total points
ID: 17994805
hey i think u only have a problem in the reponseXML change it to responseText and see i think it will work
0
 

Author Comment

by:Sh_Rashed
ID: 17994871
woow . It display the Item serial number in the alter message .. but it doesn't spilt them.

after alerting the serial number it shows me an error message .. ?
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17994884
send me the code after the alert message and send me the error message and line number
0
 

Author Comment

by:Sh_Rashed
ID: 17994898
look at this http://www.4img.com/ar/up/06/11/22/d814f4e3dcf9e6f473e213232b9ba115.jpg

function writeSN(snXML){

var result = snXML;

alert(snXML);

array2 = result.spilt("#");

var dropdown = document.getElementById("dropdown2");

for ( var I = 0 ; I < array2.length ; I++){


dropdown.options.add(new Option(array2[I],array2[I]));

}
}

this is my display html:

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" language="javascript" src="ajax1.js"></script>
<script type="text/javascript" language="javascript" src="cart.js"></script>

</head>

<body>

<form name = "ItemsForm" method="POST" action="cart.do">
      
<p>Item Model :<select size="1" name="itemModel" onchange= "getSN(this.options[this.selectedIndex].value)" >
 
      <option name ="itemModel" value="HP500">Hp500</option>
      <option name ="itemModel" value="HP600">Hp600</option>
      <option name ="itemModel" value="HP700">Hp700</option>
      </select></p>
       
      <p>Item Serial Number : <select size="1" name="ItemSN" id ="dropdown2"></select></p>
      
       
      
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>



 
</ul>

</body>

</html>
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17994909
send me the detail error message and send me the line number
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17994923
okay fine which line is 23
0
 

Author Comment

by:Sh_Rashed
ID: 17994930
line 23
char1

Error: object doesn't support thie property or method

code:0
0
 

Author Comment

by:Sh_Rashed
ID: 17994974
it works thank u .. it was spelling mistake

array2 = result.spilt("#"); <--- here it should be array2 = result.split("#");

Thank u .. u deserve the points
0
 
LVL 5

Expert Comment

by:deeppra
ID: 17995063
okay fine.... Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question