Forum Moderators: open

Message Too Old, No Replies

Building URL stringg in Javascript

         

tommy1980

2:36 pm on Jan 20, 2005 (gmt 0)

10+ Year Member



I have page where I can add resources to a task. To add an resource you click "add resource", a window opens with a select menu with multiple selections allowed.

Once the Resources have been chosen then you click add, it builds a string closes the pop up window and pass the sequence number into the parent URL.

Problem:
The problem is that is only passing through the first selected Resource and not adding the rest. So it isnt building the string for the URL (eg. pagename.asp?Resource=1,2,3,4,5,8)

The Code:
function selResource(lngTaskSeq)
{
for (var i=0; i<formName.fieldName.length; i++)
{
if (formName.fieldName[i].selected)
{
window.opener.location="PageName.asp?page=submit&assign=" + formName.fieldName[i].value + "&taskseq=" + lngTaskSeq
break;
}
}
window.close(this);
}

any help is much appreciated.

Tom

rocknbil

6:27 pm on Jan 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wild stab here, I work a lot with selects but not multiple selects but I might be onto something:

if (formName.fieldName[i].selected) .....

formName= form object
FieldName = Multiple select object
shouldn't it be

formName.FieldName.options[i].selected

?