• Post Reply Bookmark Topic Watch Topic
  • New Topic

accessing data in without ambiguity between same element.  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, i m using 1 dropdown and a textarea to display the data i recieved from database using ajax.


MY AJAX CODE TO INSERT IN ELEMENT ----

document.getElementById("add_detail").innerHTML =response;

document.getElementById("complete_detail").innerHTML =response1;


MY HTML CODE ----------

<div name ="add_detail" id="add_detail">
<select name="add_detaila" id="second_drpdwn" onchange="GetSelectedItem2(this)" >
<option>Select City</option>
</div>


<div id="complete_detail" name="asd">
<textarea id="asd" name="comp_det" rows="30" cols="70" >
</textarea>
</div>



But the above code is not working, onselecting valueu from the dropdown textarea is disapeearing.

However If I add a dropdown list of the same id or a diff id proper result are being displayed.
My Edited code is -


HTML COde----

<div name ="add_detail" id="add_detail">
<select name="add_detaila" id="second_drpdwn" onchange="GetSelectedItem2(this)" >
<option>Select City</option>
</div>

<div name ="add_detail" id="add_detail">
<select name="add_detaila" id="second_drpdwn" onchange="GetSelectedItem2()" >
<option>Select City</option>
</div>


<div id="complete_detail" name="complete_detail">
<textarea id="asd" name="comp_det" rows="30" cols="70" >
</textarea>
</div>




Can anyone tell me hows that possible. Because the name and id of both the dropdown here are same. NOw th text area is showing proper result.
 
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ids are singular, you can only have one per page.

Eric
 
Author and ninkuma
Marshal
Posts: 66399
156
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, divs don't have names.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!