Current location: Hot Scripts Forums » General Community » Script Requests » 2 multiple dropdown lists


2 multiple dropdown lists

Reply
  #1 (permalink)  
Old 08-22-08, 08:55 AM
theighost theighost is offline
Newbie Coder
 
Join Date: Jul 2008
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
2 multiple dropdown lists

hi,

i would like to make two multiple dropdown lists one beside the other, and between them are two buttons.

the first dropdown will contain a information from a database,

the second dropdown will be empty and i will be able to add/remove , to/from this dropdown using the buttons.

for example, i will name the first dropdown (care models) which will contain all car models in the world.

I will name the second dropdown (my favorite cars) which at first will be empty.

using the buttons i will add some cars to fro (car models) to (my favorite cars) and verso.

help please...i need the ajax script as the html is known for me!
Reply With Quote
  #2 (permalink)  
Old 08-26-08, 08:21 AM
theighost theighost is offline
Newbie Coder
 
Join Date: Jul 2008
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
I found the javascript myself, its functioning, i will put it so that if someone faces the same problem doesn't take him forever to make it.

THE JAVASCRIPT:

javascript Code:
  1. <script type="text/javascript">
  2. function left()
  3. {
  4.     var model=document.getElementById('model');
  5.     var model2=document.getElementById('model2');
  6.    
  7.     while (model != '')
  8.     {
  9.     model.options[model.length]=model2.options[model2.selectedIndex];
  10.     }
  11. }
  12. function right()
  13. {
  14.     var model=document.getElementById('model');
  15.     var model2=document.getElementById('model2');
  16.    
  17. while (model2 != '')
  18. {
  19.     model2.options[model2.length]=model.options[model.selectedIndex];
  20. }
  21. }
  22. </script>


THE DROPDOWN LIST(BOXES):
HTML Code:
<tr>
<td>all models: </td>
<td></td>
<td>selected models: </td>
</tr>

<tr>
<td>
<select name="model[]" multiple  size="8" id="model">
//here u put all the options from the database or static data. u do all that using <option value="model_id">model</option>
</select>


</td>
<td><div align="center">
<input type="button" value=">>" name="add" onclick="right()"> <br>
<input type="button" value="<<" name="remove" onclick="left()">
</div>
</td>

<td>
<div align="right">
<select name="model2[]" multiple size="8" id="model2">
//here u put the selected models only.
</select>
</td>
</tr>

Last edited by Nico; 08-27-08 at 02:23 AM. Reason: Wrappppers....
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mass Install Wordpress to multiple websites scriptillusion General Advertisements 0 04-10-06 11:31 PM
Dynamicly filling out an INPUT field with dropdown lists gudmo PHP 0 02-01-05 11:04 AM
Multiple dropdown plus link problem bastiaan JavaScript 0 11-17-03 04:22 PM


All times are GMT -5. The time now is 09:19 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.