CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Ajax and Design (http://www.codingforums.com/forumdisplay.php?f=55)
-   -   related comboboxes (http://www.codingforums.com/showthread.php?t=288305)

docock 02-26-2013 09:56 AM

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 ?

sunfighter 02-26-2013 03:46 PM

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>



All times are GMT +1. The time now is 05:27 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.