Results 1 to 3 of 3

Thread: simple vbscript question

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Nashville, TN
    Posts
    54
    I have a html page with a list box.

    <HTML>

    <BODY>
    <form name=blah>
    <SELECT size=2 id=select1 name=select1 style="WIDTH: 80px; HEIGHT: 130px">
    <OPTION>test1</OPTION>
    <OPTION>test2</OPTION>
    <OPTION>test3</OPTION>

    </SELECT>

    <BR>
    <BR>
    <BR>
    <input type="button" value="Move" onclick='doo();'>
    </form>



    I can't for the life of me add to this list. I thought it would be document.blah.select1.add "test4"
    ,But I keep getting a type mismatch error. Can anyone help me on this.

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    I would recomend also using the value attribute in the option tags or you wont be able to get any data from this select after you submit to your processing page. (Only the Value is passed, not the innerText of the option tag)

    Here is code to add one in javascript:
    Code:
    	var colOptions = blah.select1.options;
    	var objOption;
    		
    	objOption = document.createElement("OPTION");
    	colOptions.add(objOption);
    	objOption.innerText="Test4";
    	objOption.value="4";
    VBScript:
    Code:
    	Dim colOptions
    	Dim objOption;
    	
    	Set colOptions =  = blah.select1.options
    	Set objOption = document.createElement("OPTION")
    
    	colOptions.add(objOption)
    	objOption.innerText="Test4"	objOption.value="4"
    
    	Set objOption = Nothing
    	Set colOptions = Nothing
    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
    Member
    Join Date
    Feb 2000
    Location
    Nashville, TN
    Posts
    54
    Thanks for the help friend

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