Current location: Hot Scripts Forums » General Web Coding » JavaScript » Select List insert into DB


Select List insert into DB

Reply
  #1 (permalink)  
Old 01-11-05, 06:09 PM
The Omega The Omega is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Select List insert into DB

I have a select list that doesnt want to behave. The left side willbe/is generated by the database and the right side is the insert field. The select list works properly and I can switch it from one list to the other. However, when I go to submit the form it does not accept the items in the right list unless I manually select them and then press submit.

I have tried to use a highlight text script like used for textboxes but it doesnt work on the select boxes

Select List:
PHP Code:

"<t d colspan=""1"">" vbNewLine _

"Recipients: <br/>" vbNewLine _
"<select multiple size=""5"" name=""list1"" style=""width:100"">" vbNewLine _
"<option value=""1"">Ben Smith</option>" vbNewLine _
"<option value=""D"">Dispatch</option>" vbNewLine _
"<option value=""V"">Dev</option>" vbNewLine _
"</SELECT>" vbNewLine _
"</t d>" vbNewLine _
"<t d>" vbNewLine _
"<input type=""button"" onClick=""move(this.form.frmMemoRecipients,this.form.list1)"" value=""<<"">" vbNewLine _
"<input type=""button"" onClick=""move(this.form.list1,this.form.frmMemoRecipients)"" value="">>"">" vbNewLine _
"</t d>" vbNewLine _
"<t d>" vbNewLine _
"<br/>" vbNewLine _
"<select multiple size=""5"" name=""frmMemoRecipients"" style=""width:100"">" vbNewLine _
"</select>" vbNewLine _
"</t d>" vbNewLine _
"</t r>" vbNewLine _
"<t r>" vbNewLine _
"<t d colspan=""4"" valign=""top"" align=""right"">" vbNewLine _
"<input onClick=""selectText()"" type=""Submit"" Value=""Submit"" Name=""Submit"">" vbNewLine _
"</t d>" vbNewLine _
"</t r>" vbNewLine 
Move & Highlight Javascript
Code:
<script type="text/javascript">
function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
   }
}
arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
   }
}
//  End -->
</SCRIPT>
 **********
 // Copyright 2001 by www.CodeBelly.com
 // Do *not* remove this notice.
 function selectText(){
 document.memoform.frmMemoRecipients.focus();
 document.memoform.frmMemoRecipients.select();
 }
 </script>

Last edited by The Omega; 01-11-05 at 06:11 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-12-05, 01:51 PM
The Omega The Omega is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
<script language="JavaScript"> 
function selectAllOptions(obj) {
	for (var i=0; i<obj.options.length; i++) {
		obj.options[i].selected = true;
		}
	}
 </script>
Code:
onClick=""selectAllOptions(document.memoform.frmMemoRecipients)""

After not recieving a reply, I did a bit more searching and finally picked up a lead from a friend and from Snitz message board.... the above is the solution....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
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 09:34 PM
Why won't select list item insert into database? gavacho PHP 2 12-05-08 07:38 PM
Pulling data from multiple select list bayside2004 PHP 4 12-09-04 08:06 AM
need help with retaining select list values sky4est PHP 1 03-25-04 06:00 PM
MySQL table problem perleo PHP 9 12-16-03 02:16 PM


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