Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-26-2013, 09:56 AM   PM User | #1
docock
Regular Coder

 
Join Date: Feb 2007
Posts: 194
Thanks: 20
Thanked 1 Time in 1 Post
docock is an unknown quantity at this point
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 ?
docock is offline   Reply With Quote
Old 02-26-2013, 03:46 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,374
Thanks: 18
Thanked 349 Times in 348 Posts
sunfighter is on a distinguished road
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>
sunfighter is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:33 PM.


Advertisement
Log in to turn off these ads.