Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select box move

Status
Not open for further replies.
Jun 5, 2006
40
0
0
hey i'm moving things from one select box to another they are side by side and the left one has information and the right one does to i'm trying to make it where it will post back when they add someting or subtract something from the left box any suggestions?

Remember free things are fun but they can come with an emotional price tags..
 
You have not really defined your question.
You want to do something when the value in the left box changes but you have not said what.

Use an onchange event in the select box on the left to trigger the action you want to happen. I cannot be more specific without knowing what the effect should be.


Google, you're my hero!
 
I made something like this a while ago and keep it on file. I use it for reference and stuff, hopefully it can be of some use to you.

Code:
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
		<script>
		var checklist = new Array();
		var listi = 0;
		function init_checklist()
		{
			var objSub = document.getElementsByName("checklist")[0];
			listi = objSub.length;
			if(listi != 0 && checklist.length == 0)
			{
				for(var i = 0; i < listi; ++i)
				{
					checklist[i] = objSub.options[i].text;
				}
			}
		}

		function addcheck()
		{
			var obj = document.getElementsByName("individualcheckamount")[0];
			var amount = obj.options[obj.selectedIndex].value * 1;
			var txt = obj.options[obj.selectedIndex].text;
			if(amount == 0)
			{
				return;
			}
			init_checklist();
			var objSub = document.getElementsByName("checklist")[0];
			var checklist_values = "";
			checklist[listi] = amount;
			var listOpt = document.createElement("option");
			listOpt.value = checklist[listi];
			listOpt.text = txt + " - " + checklist[listi];
			objSub.add(listOpt);
			var checkamount = 0;
			for(var i = 0; i <= listi; ++i)
			{
		        checkamount += checklist[i] * 1;
		        checklist_values += checklist[i] + ":";
		    }
		    ++listi;
		    document.getElementsByName("individualcheckamount")[0].value = "";
			document.getElementsByName("checklist_values")[0].value = checklist_values;
		}

		function removecheck()
		{
			var objSub = document.getElementsByName("checklist")[0];
			var si = objSub.selectedIndex;
			if(si == -1)
				{
					alert("Please select a check amount to delete!");
					return;
				}
		    init_checklist();
			objSub.options[si] = null;
		    var checklist_new = new Array();
		    var j = 0;
		    for(var i = 0; i < listi; ++i)
			{
				if(i != si)
				{
					checklist_new[j++] = checklist[i];
				}
			}
			--listi;
			checklist = checklist_new;
		}
		</script>
		<title>Add & Delete from a Select List</title>
	</head>
	<table border="1" align="center">
		<tr>
			<td>Amount:</td>
			<td><select type="text" name="individualcheckamount" maxlength=7>
				<option value="2" selected>choice 2</option>
				<option value="6">choice 6</option>
				<option value="1">choice 1</option>
				<option value="5">choice 5</option>
				</select>
	 		</td>
		</tr>
		<tr>
			<td><button onClick="javascript:addcheck();"> Add </button></td>
			<td><button onClick="javascript:removecheck();"> Delete </button></td>
		</tr>
		<td align=right colspan="2"><select name="checklist" size="4" maxlength=7 style='width:140px'>
		<input type=hidden name=checklist_values>
	</table>

I don't know the answer but my good friend Google does.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top