Date:  05/14/2002 07:53:10 PM Msg ID:  000626
From:  FoxWeb Support Thread:  000621
Subject:  Re: Re: Re: Multiple select from a list box

Are you using FoxWeb 1.X? If yes, then this is the reason why you got confused by the code we posted in our reply. That code uses methods that were introduced in FoxWeb 2. Here's some code that applies to FoxWeb 1. Obviously you don't need your JavaScript code if you implement this on the server:

PROCEDURE submit_req

M.zinstcode = ''

FOR i = 1 TO TotFields('minst_code')

M.zinstcode = M.zinstcode + FormField('minst_code', i) + ' '

NEXT

* Remove the trailing space

M.zinstcode = TRIM(zinst_code)

M.finstcode = FormField('xinst_code')

UPDATE aaulog;

SET last_acces = datetime(),;

ainstcode = M.zinstcode;

WHERE alltrim(xinst_code) == alltrim(M.finstcode)

SELECT html_code FROM forms WHERE form_id == "XXX" INTO ARRAY FormTxt

html_out = mergetxt(FormTxt)

return

FoxWeb Support Team
support@foxweb.com

Sent by Nancy Remillard on 05/14/2002 01:15:15 PM:

I have to tell you, that I feel really stupid, because I can't figure out where it is I need to put the "For i..." you sent. I have been going only allowing only single selections, or using checkboxes, but I REALLY want to learn how to allow a multiple selection. I have tried so many things my brain hurts! This is what my html looks like:

<HTML>

<HEAD>

<TITLE>AAU Data Base Project</TITLE>

<script language="JavaScript">

function reportMultiple()

{

var zinst_code = "";

var the_select = window.document.form_1.minst_code;

for (loop=0; loop < the_select.options.length; loop++)

{

if (the_select.options[loop].selected == true)

{

zinst_code += the_select.options[loop].text + " ";

}

}

alert("you selected " + zinst_code);

}

</script>

</HEAD>

<FONT FACE="Times New Roman,Times"><FONT POINT-SIZE="11">

<form name="form_1" onSubmit="reportMultiple(); return true;" ACTION="/scripts/foxweb.exe/submit_req@C:\INETPUB\SCRIPTS\AAU\aau" METHOD="POST">

<INPUT TYPE="hidden" NAME="ainst_code" VALUE="iu"><!--This just passes who it is asking for the data -->

<SELECT NAME="minst_code" SIZE="5" MULTIPLE>

<Option VALUE=" ">-- Select Institution(s) --<OPTION VALUE="0001">Columbia University

<OPTION VALUE="0002">Duke University

<OPTION VALUE="0003">Indiana University

<OPTION VALUE="0004">Princeton Univeristy

<OPTION VALUE="0005">Rutgers University

<OPTION VALUE="0006">University of California - Berkley

<OPTION VALUE="0007">Univeristy of California - San Diego

</SELECT>

<p>

<input type="submit" value="SUBMIT">

</form>

</FONT></FONT>

</BODY>

</HTML>

I put the JavaScript in because I wanted to see if the list box was even allowing the multiple selections. Once I was sure I could "trap" the information, I figured it SHOULD let me just store zinst_code to my table on the server side, I only am able to see the first selection. I have tried MANY things, but none seem to work.

To ME...it seemed like all I would need to do was tell the .prg to store zinst_code, but that stores nothing at all into the table. (If I tell it M.zintcode=FormField('minst_code') it stores ONE value.)

Here is the .prg that I am using to store information regarding the selection.

PROCEDURE submit_req

M.zinstcode = FormField('zinst_code')

M.finstcode = FormField('xinst_code')

UPDATE aaulog;

SET last_acces = datetime(),;

ainstcode = M.zinstcode;

WHERE alltrim(xinst_code) == alltrim(M.finstcode)

SELECT html_code FROM forms WHERE form_id == "XXX" INTO ARRAY FormTxt

html_out = mergetxt(FormTxt)

return

As before, any help will be appreciated.