Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


dynamical add option

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,62754
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> dynamical add option
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 dynamical add option - 7/25/2008 12:43:49 AM   
  jim

 

Posts: 3
Score: 0
Joined: 5/26/2005
From: USA
Status: offline
Hi Friends,
I try to add a option to select. But I got an error.
How to fix it?
Please review my code.
Thanks

New weber
****************
<html><head><title>position set</title>
<script language="vbscript" >

Sub button1_onclick()

set newOption = document.createElement("OPTION")

newOption.Text = "A new Option"
newOption.Value = "N"
selectb.Add newOption
alert "hh"
End Sub
</script>
</head>
<body><form>

<select id="selectX" name="selectb" size="8" >
<option value="original1" selected="selected">Position 1</option>
</select>
<br>

<input type="button" name="button1" value="add postion" ><br>

</form>
</body>
</html>

_____________________________

jim
 
 
Post #: 1
 
 RE: dynamical add option - 7/25/2008 1:05:20 AM   
  ehvbs

 

Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Jim,

just refer to the select via document.all - like this:

<html>
<head>
<title>position set</title>
<script language="vbscript" >

Sub button1_onclick()
set newOption = document.createElement("OPTION")
newOption.Text = "A new Option"
newOption.Value = "N"
document.all.selectb.Add newOption
End Sub

</script>
</head>
<body>
<form>
<select id="selectX" name="selectb" size="8" >
  <option value="original1" selected="selected">Position 1</option>
</select>
<br>
<input type="button" name="button1" value="add postion" ><br>
</form>
</body>
</html>

Good luck!

ehvbs

(in reply to jim)
 
 
Post #: 2
 
 RE: dynamical add option - 7/25/2008 5:11:13 AM   
  jim

 

Posts: 3
Score: 0
Joined: 5/26/2005
From: USA
Status: offline
Thanks for your help!!
Nice weekend for YOU!!

_____________________________

jim

(in reply to ehvbs)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> dynamical add option Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts