Results 1 to 4 of 4

Thread: Why cant anyone help!!!!????

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Red face

    ......all I want to do is "read" thru a combobox in ASP and "response.write" each and every option within that combobox - selected or not!!

    In VB I do something like this and it works - how can I do this in ASP.

    'VB CODE - it "reads" thru the combo/listbox and prints each item....
    Private Sub Command1_Click()
    Dim n As Integer

    For n = 0 To 3
    Combo1.ListIndex = n
    Print Combo1.Text
    Next

    End Sub


    I have posted a thread called "Please - this cannot be so difficult" which explains this in detail and no-one seems to be able to help.

    Please, anyone, help.

    Thanks,
    T

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    When a form is submitted, only it's selected options are passed.

    If you need to send them all, you will have to create a hidden select tag that is passes along with the form that mirrors the data in the other combo, OR on submit, loop through the options collection of the select tag, and put them into a comma or other delimited hidden textbox.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343
    Hi (again) Monte96,

    The comma delimited hidden textbox seems to be the answer. The "problem" is that the user can select anything from 1 to 500 options...(I dont really know whether that IS actually a problem...).

    Could you please help me with some example code of doing this. Firstly how to create the comma delimited textbox and secondly how to RETRIEVE whatever is in there, in my SECOND page.

    Thanks a lot,
    T

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    lets see.....

    I'm assuming you already know how to create the hidden textbox.. that's just simple html..

    Doing this from memory, but I think this should do it:

    Code:
    MyForm_onsubmit()
    {
    	var colOptions = MyForm.MyCombo.options;
    	var intList;
    	var strOptions = new String("");
    
    	strOptions = colOptions[0].value
    
    	for(intList=1; intList < colOptions.length; intList++)
    {
    		strOptions = strOptions + ', ' + colOptions[intList].value
    }
    
    	MyForm.MyHiddenTextbox.value = strOptions
    
    }
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width