User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 425,795 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,123 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1639 | Replies: 2 | Solved
Reply
Join Date: Oct 2007
Posts: 63
Reputation: still_learning is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
still_learning still_learning is offline Offline
Junior Poster in Training

drop down menu call javascript function

  #1  
May 28th, 2008
Hey guys,

I am trying to make a drop down menu that gives options such as (right, left, center) so that I can choose one of those and align the text in one of my layers. I am having trouble figuring out how to make this work so if someone can help me that would be great.

Basically I need a drop down menu with those three options, and when one of the options is chosen, I need it to call a javascript function onchange (i don't want to use a button, i just want to align the text instantly) and then I need the javascript function to use getElementById('mylayer') to change the alignment of the text in that layer. Can anyone help me? I'm sure it is simple and involves the values of my drop down menu, but I cannot manage to figure it out. Thanks!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Posts: 1
Reputation: Nandish is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
Nandish Nandish is offline Offline
Newbie Poster

Re: drop down menu call javascript function

  #2  
May 29th, 2008
Originally Posted by still_learning View Post
Hey guys,

I am trying to make a drop down menu that gives options such as (right, left, center) so that I can choose one of those and align the text in one of my layers. I am having trouble figuring out how to make this work so if someone can help me that would be great.

Basically I need a drop down menu with those three options, and when one of the options is chosen, I need it to call a javascript function onchange (i don't want to use a button, i just want to align the text instantly) and then I need the javascript function to use getElementById('mylayer') to change the alignment of the text in that layer. Can anyone help me? I'm sure it is simple and involves the values of my drop down menu, but I cannot manage to figure it out. Thanks!


try this.........

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. function alignl(ele){
  6. document.getElementById('lay').style.align=ele;
  7. }
  8. </script>
  9. </head>
  10. <body>
  11. <layer id='lay'></layer>
  12. <select id='s' name='s' onchange="alignl(this.value);">
  13. <option value="left">left</option>
  14. <option value="right">right</option>
  15. <option value="center">center</option>
  16. <option value="top">top</option>
  17. </select>
  18. </body>
  19. </html>
Last edited by peter_budo : May 31st, 2008 at 6:27 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
Join Date: Oct 2007
Posts: 63
Reputation: still_learning is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
still_learning still_learning is offline Offline
Junior Poster in Training

Re: drop down menu call javascript function

  #3  
May 29th, 2008
Thanks for the solution. I had already solved it myself, but since you posted the same exact solution that I came up with myself I will go ahead and add to your reputation.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 3:23 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC