Current location: Hot Scripts Forums » Programming Languages » PHP » Selected combo box items are insert into lisbox


Selected combo box items are insert into lisbox

Reply
  #1 (permalink)  
Old 02-17-09, 03:43 AM
ektakamra ektakamra is offline
New Member
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Selected combo box items are insert into lisbox

I want to insert items from combo box to list box by clicking onto the item from combo box.
Reply With Quote
  #2 (permalink)  
Old 02-17-09, 04:10 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
Try this. No PhP needed, just javascript:

Code:
<html>
<head>
	<script language="JavaScript">
		function addToList(cb){
			var select_list_selected_index = cb.selectedIndex;
			var text = cb.options[select_list_selected_index].text;
			var value = cb.value;
			var myList = document.getElementById("lst");
	
			myList.size = myList.size + 1;
			myList.options[myList.length] = new Option(text, value);
		
		}
    </script>
</head>
<body>
<form>
<select size="0" id="lst" name="lst">
</select>

<select size="1" id="cb" name="cb" onchange="addToList(this);">
	<option value="1" text="Option 1">Option 1</option>
	<option value="2" text="Option 2">Option 2</option>
	<option value="3" text="Option 3">Option 3</option>
</select>

</form>
    

</body>
</html>
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
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
Problem with Auto Dealer Script nuzzle PHP 17 04-14-10 08:34 PM
Help a Novice with inserting from a combo box kposki PHP 5 07-11-08 03:25 AM
Combo Box Question iamtat Visual Basic 3 10-18-05 01:49 PM
help in combo box mathfxr ASP 0 12-28-04 10:05 PM


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