Jump to content

Concatenate commands


Guest henkvisser

Recommended Posts

Guest henkvisser

Hi. I'm not sure if it is possible but here's the code I want to use;

Sub CheckBoxVisibility(sControlName)	Dim checkbox, editbox, picklist	checkbox = "chk" & sControlName & ".state"	editbox = "edb" & sControlName & ".Visible"	picklist = "pkl" & sControlName & ".Visible"	  if checkbox = cbChecked then		 editbox = True		 picklist = False	  elseif checkbox = cbUnchecked then		 editbox = False		 picklist = True	  end ifend subSub chkSM1Click(Sender)	Dim sControlName	sControlName = Right(Sender.name, 3)	Call CheckboxVisibility(sControlName)End Sub

In short, I have controls like edbSM1 (editbox), edbSM2, edbSM3, chkSM1 (checkbox), chkSM1, pklSM1 (picklist), pklSM2. It would save time to use a functions as above to use dynamic controls. But it doesn't recognize

checkbox = "chk" & sControlName & ".state"

as a control and its attribute, so the if doesn't work and always returns false. It should return

chkSM1.state

which is obviously the state of the checkbox. So is it possible to concatenate controls/commands???

Link to comment
Share on other sites

It has been a long time since I worked regularly with VBScript, but don't you have to use the DOM to get at an element in the HTML?If you ran

checkbox = "chk" & sControlName & ".state"

checkbox should just contain a string ("chkSM2.state" for example);In javascript, you'd have to use something like this:

var checkbox = document.getElementById("chk" + sControlName);var state = checkbox.state;

EDIT: If you can access the state of a checkbox by using chkSM1.state, then you might try something like this:

checkbox = "chk" & sControlNamestate = checkbox.state

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...