Select Box Updates DIV on the page

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Oct 2009
Posts: 2
Reputation: sops21 is an unknown quantity at this point 
Solved Threads: 0
sops21 sops21 is offline Offline
Newbie Poster

Select Box Updates DIV on the page

 
-1
  #1
Oct 15th, 2009
I have a select box with information about people in it. When you click on their name in the select box, I'm trying to display information (Name, Address, Height, Weight) about them inside of a <div>. Here is what I have so far:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <form>
  2.  
  3. <SELECT NAME="list1" MULTIPLE SIZE=20 class="set_width" id='developer'>
  4.  
  5.  
  6. <option value=43>John Doe </option>
  7. <option value=42>Jane Doe </option>
  8. <option value=38>Bob Smith </option>
  9.  
  10. </SELECT>
  11. </form>
  12.  
  13. <div id="output">
  14.  
  15. </div>

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3.  
  4. $("#developer").change(onSelectChange);
  5.  
  6. });
  7.  
  8. function onSelectChange(){
  9. var selected = $("#developer option:selected");
  10. var output = "";
  11. if(selected.val() != 0){
  12. output = "You Selected " + selected.text();
  13. }
  14. $("#output").html(output);
  15. }
  16. </script>

Now, what I am thinking is that I need to use selected.val() to pull the value (we'll call it id)of each person and have that id correspond with a row in an array. That row contains all of the information that I need.

Does this make sense? How would I go about doing something like this? Any suggestions would be appreciated.

I just realized that I posted this in the wrong java forum. If someone would move it that would be great.
Last edited by sops21; Oct 15th, 2009 at 6:37 pm. Reason: Posted in wrong forum.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,188
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 482
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer
 
0
  #2
Oct 15th, 2009
Java and JavaScript are not the same thing. Java is product of Sun Microsystems where JavaScript is product of Netscape. Java is an programming language, JavaScript is obviously scripting language.
Request to move post to correct section already sent.
Last edited by peter_budo; Oct 15th, 2009 at 6:39 pm.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: sops21 is an unknown quantity at this point 
Solved Threads: 0
sops21 sops21 is offline Offline
Newbie Poster
 
0
  #3
Oct 15th, 2009
Thanks for putting in the request. I noticed it was in the wrong forum as soon as I posted it. Sorry.
Reply With Quote Quick reply to this message  
Reply

Tags
ajax, forms, java, listbox

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC