943,982 Members | Top Members by Rank

Ad:
Oct 15th, 2009
-1

Select Box Updates DIV on the page

Expand Post »
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.
Reputation Points: 10
Solved Threads: 5
Newbie Poster
sops21 is offline Offline
16 posts
since Oct 2009
Oct 15th, 2009
-1
Re: Select Box Updates DIV on the page
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.
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,658 posts
since Dec 2004
Oct 15th, 2009
0
Re: Select Box Updates DIV on the page
Thanks for putting in the request. I noticed it was in the wrong forum as soon as I posted it. Sorry.
Reputation Points: 10
Solved Threads: 5
Newbie Poster
sops21 is offline Offline
16 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Form without action "imitate" of other Form (which do have action) ???
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: can i get this php code in javascript??





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC