Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Posts
    217
    Thanks
    25
    Thanked 1 Time in 1 Post

    Question related comboboxes

    Hi there,

    I'm new to ajax and need to build something like this:
    https://www.marktplaats.nl/syi/plaatsAdvertentie.html

    The idea is that someone picks a value from the first combobox, and then a php script will fill the related values into a second combobox.

    I haven't got a clue how to do this though.. I guess it's something with submitting the first combobox?

    I've searched for hours for a tutorial on this without any luck.

    Can anyone provide me an example on how to do this or give me a link to a proper tutorial ?

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,180
    Thanks
    23
    Thanked 603 Times in 602 Posts
    You might not have found it calling it a combobox. Try listbox.
    A place to read http://www.hscripts.com/scripts/Java.../move-list.php
    And code:
    Code:
    <table border=1 align=center valign=center>
    <tr><td>From Group</td><td></td><td>To Group</td></tr>
    <tr><td>
    <select id=xxx multiple size=7 style="width:100;">
    
    	<option>Pink</option>;
    	<option>2</option>;
    	<option>Green</option>;
    	<option>5</option>;
    	<option>Yellow</option>;
    
    </select>
    </td>
    <td>
    <input type=button value=">>" onclick=moveoutid()>
    <input type=button value="<<" onclick=moveinid()>
    </td>
    <td>
    <select id=yyy multiple size=7 style="width:100;">
    <script type="text/javascript">
    for(var j=0;j<to_array.length;j++)
    {
    	document.write('<option>'+to_array[j]+'</option>');
    }
    </script>
    </select>
    </td></tr>
    </table>
    
    
    <script type="text/javascript">
    
    function moveoutid()
    {
    	var sda = document.getElementById('xxx');;
    	var len = sda.length;
    	var sda1 = document.getElementById('yyy');
    	for(var j=0; j<len; j++)
    	{
    		if(sda[j].selected)
    		{
    			var tmp = sda.options[j].text;
    			var tmp1 = sda.options[j].value;
    			sda.remove(j);
    			j--;
    			var y=document.createElement('option');
    			y.text=tmp;
    			try
    			{sda1.add(y,null);
    			}
    			catch(ex)
    			{
    			sda1.add(y);
    			}
    		}
    	}
    }
    
    
    function moveinid()
    {
    	var sda = document.getElementById('xxx');
    	var sda1 = document.getElementById('yyy');
    	var len = sda1.length;
    	for(var j=0; j<len; j++)
    	{
    		if(sda1[j].selected)
    		{
    			var tmp = sda1.options[j].text;
    			var tmp1 = sda1.options[j].value;
    			sda1.remove(j);
    			j--;
    			var y=document.createElement('option');
    			y.text=tmp;
    			try
    			{
    			sda.add(y,null);}
    			catch(ex){
    			sda.add(y);
    			}
    
    		}
    	}
    }
    </script>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •