Usering script to display the contents(text,value) of the option of a html listbox 
Author Message
 Usering script to display the contents(text,value) of the option of a html listbox

Hi,

I have created an asp page with a table containing a listbox. The listbox is
included by inserting the code from the server <%=BuildListBox()%>. I am
then using script to duplicate the rows and plan to keep the IDs of the
listboxes unique. I can not get the value/text of the first listbox to
create the options to add to the other listboxes. I have tried the
following:

MsgBox document.all.cboMediaTypeID1.options(1).value
    And
MsgBox document.all("cboMediaTypeID1").options(1).value

and other variences. Does anyone have some idea on how go about this?

Thanks,
Paul



Tue, 10 May 2005 09:39:20 GMT  
 Usering script to display the contents(text,value) of the option of a html listbox
I tried the code below and it worked as expected.


<HTML>
<HEAD>
<META name=VI60_defaultClientScript content=VBScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--

Sub button1_onclick
        'document.location.reload()
        MsgBox document.all.select1.options(1).value
End Sub

-->
</SCRIPT>
</HEAD>
<BODY>

<%
Dim listBox
listBox = "<SELECT size=2 id=select1 name=select1 style='width:50px'>" + _
                                "<OPTION value=1>1</OPTION>" + _
                                "<OPTION value=2>2</OPTION>" + _
                                "<OPTION value=3>3</OPTION>" + _
                        "</SELECT>"
%>

<form method="post" action="autoPost.asp" name="myFrm" >
<%=listBox%>
<INPUT type="submit" value="Submit" id=cmdLogin name=cmdLogin>
<INPUT type="button" value="Button" id=button1 name=button1>
</form>

</BODY>
</HTML>

What's your problem? Is there any error? If it is case, what the error is
and which line of the code is where the error raised? Any code snippet?

Gary

This posting is provided "AS IS", with no warranties, and confers no
rights. Enjoyed ASP.NET? http://www.asp.net



Fri, 13 May 2005 13:09:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Displaying contents of VBScript Array on HTML frame

2. How to display the content of a text file on an ASP

3. changing select options based on text value in another field

4. I need to display the text of an html file in a text box

5. Displaying text/input field depending on checkbox value

6. Display a text file in a html document.

7. Display Text From DataBase in HTML Format

8. set content type to text/html programaticaly?

9. Option button to display text in textbox

10. To displaying NULL database values on an HTML page

11. VB Script: How to Open a remote webpage as text to view contents

12. reading contents of remote HTML pages into asp script

 

 
Powered by phpBB® Forum Software