Article ID: 197968
Article Last Modified on 7/2/2004
<!--#INCLUDE FILE="_ScriptLibrary/TextBox.ASP"-->
<SCRIPT LANGUAGE=JavaScript RUNAT= Server>
function _initTextbox1()
{
for (i=1; i<=3; i++)
{
eval('Textbox' + i + '.setStyle(TXT_TEXTBOX);')
eval('Textbox' + i + '.setMaxLength(20);')
eval('Textbox' + i + '.setColumnCount(20);')
}
}
function _Textbox1_ctor()
{
for (i=1; i<=3; i++)
CreateTextbox('Textbox' + i, _initTextbox2, null);
}
</script>
<%
for (i=1; i<=3; i++)
eval ('Textbox' + i + '.display();')
%>
The following code segment clears the three textboxes in a loop:
<SCRIPT ID=serverEventHandlersJS LANGUAGE=javascript RUNAT=Server>
function Button1_onclick() {
var i;
for (i=1; i<=3; i++)
eval("Textbox" + i + ".value='';")
}
</SCRIPT>
Since eval is a JavaScript intrinsic function and not available in
VBScript, you will have to use it indirectly if you are programming in
VBScript. To clear the three textboxes in a loop in VBScript, you may use
the following code, which introduces an additional function evalit:
<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
Sub Button1_onclick()
Dim i
For i = 1 to 3
evalit "Textbox" & i & ".value = " & " 'howdy' "
Next
End Sub
</SCRIPT>
<SCRIPT LANGUAGE=javascript RUNAT=Server>
function evalit(str)
{
eval(str);
}
</SCRIPT>
This is similar to the sample given in JavaScript, except the VBScript code
calls the eval method indirectly by calling the JavaScript function evalit.
Keywords: kbhowto kbscript kbctrl KB197968