Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become a ASP.NET Expert!

Join 416,721 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 2,891 people online right now.Registration is fast and FREE... Join Now!



How to add items to ASP.NET DropDown List through client side VBSCRIPT I tried out the code but i am not able to add option text. Rate Topic: -----

#1 Jhanvy  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-May 08


Dream Kudos: 0

Share |

How to add items to ASP.NET DropDown List through client side VBSCRIPT

Posted 14 May 2008 - 10:49 PM

Sub GO()

	'Create the ASPPrinter object
	Set Prn=CreateObject("ASPPrinterCOM.ASPPrinter")
	'Call the GetPrinters method
				 Printers=Prn.GetPrinters(PrintersCount)
	'P = PrintersCount & " printers were detected on your system:" 
	For i=0 To Ubound(Printers)
dim opt
opt=document.createElement("option")
' Add an Option object to Drop Down/List Box
opt.text = Printers(i)
'MsgBox "OPTION"&opt.text
 opt.value = Printers(i) 
 document.getElementById"DropDownList1").options.add(opt)		
'Assign text and value to Option object
Next
Set Prn=Nothing
End Sub


Was This Post Helpful? 0
  • +
  • -


#2 Jayman  Icon User is offline

  • Student of Life
  • Icon

Reputation: 380
  • View blog
  • Posts: 9,355
  • Joined: 26-December 05


Dream Kudos: 500

Expert In: Everything

Re: How to add items to ASP.NET DropDown List through client side VBSCRIPT

Posted 15 May 2008 - 07:27 AM

Moved to ASP.NET.
Was This Post Helpful? 0
  • +
  • -

#3 ajwsurfer  Icon User is offline

  • D.I.C Regular
  • Icon

Reputation: 14
  • View blog
  • Posts: 355
  • Joined: 24-October 06


Dream Kudos: 50

Re: How to add items to ASP.NET DropDown List through client side VBSCRIPT

Posted 22 May 2008 - 07:45 AM

This looks good except for the typo:

document.getElementById"DropDownList1").options.add(opt) 

'should be 

document.getElementById("DropDownList1").options.add(opt) 



I have VS 2008 and it seems that the line would work like this:
  Sub GO()

	'Create the ASPPrinter object
	Set Prn=CreateObject("ASPPrinterCOM.ASPPrinter")
	'Call the GetPrinters method
	Printers=Prn.GetPrinters(PrintersCount)
	'P = PrintersCount & " printers were detected on your system:"
	For i=0 To Ubound(Printers)
			
		document.getElementById("DropDownList1").Items.Add(Printers(i))
	
	 Next
	 Set Prn=Nothing
End Sub



But I would try to build a string of printer names, and display them to the screen first, just to make sure that they are really there.
Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users