MitchellVII
asked on
How to do refer to HTML elements in vbScript?
Hi,
I am conversant in Visual Basic from working on MS Access and just learning VBScript (which seems quite similar).
In Visual Basic, if I want to refer to a control on a form by name, I first establish the Form as an object, then use the name like so:
myForm.controls('myControl ").value = "Hello World!"
Let's say that I have a Function in VBScript where I want to pass the id of an input element and then asign a value to it. What wording would I use?
Function chgValues(strID)
I am conversant in Visual Basic from working on MS Access and just learning VBScript (which seems quite similar).
In Visual Basic, if I want to refer to a control on a form by name, I first establish the Form as an object, then use the name like so:
myForm.controls('myControl
Let's say that I have a Function in VBScript where I want to pass the id of an input element and then asign a value to it. What wording would I use?
Function chgValues(strID)
ASKER
Here's the function and how I think it "should" work, but it doesn't :(
'FUNCTION - Assign Value to Input from Select Choice:
Function strSelectSet(idText,objSel ect,strTyp e)
Select case strType
case "text"
document.getElementById(id Text).valu e = objSelect.options(text.sel ectedIndex ).text
case "value"
document.getElementById(id Text).valu e = objSelect.options(text.sel ectedIndex ).value
end select
End Function
The first case assigns the .text value of the option and the second case assigns the .value value of the option.
'FUNCTION - Assign Value to Input from Select Choice:
Function strSelectSet(idText,objSel
Select case strType
case "text"
document.getElementById(id
case "value"
document.getElementById(id
end select
End Function
The first case assigns the .text value of the option and the second case assigns the .value value of the option.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
On my webform, I am attempting to call this from a <select> element like so:
onChange="strSelectSet('Co mmuteCity1 ',this,'te xt')
Does nothing.
onChange="strSelectSet('Co
Does nothing.
ASKER
golf,
Ah ok, that's likely my problem. Sorry, I am such a noob at all this.
So I can't use VBScipt for anything on an ASP Page done by the user as the fill out the form, that all has to be JavaScript?
Ah ok, that's likely my problem. Sorry, I am such a noob at all this.
So I can't use VBScipt for anything on an ASP Page done by the user as the fill out the form, that all has to be JavaScript?
ASKER