Guest henkvisser Posted January 23, 2007 Report Share Posted January 23, 2007 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??? Quote Link to post Share on other sites
jesh 0 Posted January 23, 2007 Report Share Posted January 23, 2007 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 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.