dynamic lists-object not found error

Results 1 to 2 of 2

Thread: dynamic lists-object not found error

  1. #1
    Join Date
    Dec 1969

    Default dynamic lists-object not found error

    Hi everyone,<BR> I have a problem. I have a dynamic drop down list.<BR>the items for the drop down list are selected from another list by the user. he can make selections to the drop down list any time before he hits the submit button. So, the number of items in the drop down list varies.<BR><BR>I am assigning the values of these drop down items to some hidden variables.<BR><BR>like this:<BR><BR>value1=document.myForm.list1.options[2].value;<BR>document.myForm.hidtext1.value=value1<B R><BR>at the most there can be only 5 items in the drop down list.<BR>so, I have put value1,2--5 and assigned them to hidden variables,<BR><BR>Now the problem is if there are less than 5 items in the drop down box, say if there are 3,<BR>it gives be the object not found error for the 4th and 5th item.<BR><BR>it gives me document.myForm.list1.option4[4].value object not found (obviously as there is no 4th object).<BR><BR>so, how to dynamically assign these values to the hidden variables, based on the number of items in the drop down list.<BR>please help.<BR>thanks,<BR>patrick.<BR>

  2. #2
    Join Date
    Dec 1969

    Default not ASP at all, but...

    &nbsp;<BR>&#060;SCRIPT Language=JavaScript&#062;<BR>theSel = document.myForm.list1<BR>theOptions = theSel.options<BR>for ( i = 0; i &#060; theOptions.length; ++i )<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;eval("document.m yForm.hidtext"+i+".value=" + theOptions[i].value;<BR>}<BR>&#060;/SCRIPT&#062;<BR>But I do have to ask why in the world you would do this!<BR><BR>Why not simply return a single string with delimiters? Easier to process on the ASP side. Just one example.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts