"Can't use parentheses when calling a Sub" help......

  • Thread starter Thread starter zheetee
  • Start date Start date
Z

zheetee

<script type="text/vbscript">
sub setTextBoxValue(a1,a2)
thedelete.deleteTextBox.value = a1

end sub
</script>

<td>
<a href="#"
onclick="setTextBoxValue('<%#Container.DataItem("SerialNumber")%>','<%#Container.DataItem("EquipmentCategory")%>')">
<%#Container.DataItem("SerialNumber")%> </a>
</td>


when i click on <%#Container.DataItem("EquipmentCategory")%>')
then it will call sub setTextBoxValue(a1,a2) function

but it return "Can't use parentheses when calling a Sub"
may i know what is the problem??
i can create a function that more than 1 variable??
or my database connection or variable got problem??
help...
 
This may not apply here, but in straight ASP (not ASP.NET), if you have
a function such as GimmeWhatIWant(Bribes, Groupies), then in your code
you need to call it with the following statement:

call GimmeWhatIWant(500.00, "Suzie")

If you don't include the word "call " then you will get that
"parentheses" error. Again, that may not be applicable here, but I
hope that helps.
 
Does it work if you do as it says and remove the brackets?

<a href="#"
onclick="setTextBoxValue
'<%#Container.DataItem("SerialNumber")%>','<%#Container.DataItem("EquipmentCategory")%>'">
<%#Container.DataItem("SerialNumber")%> </a>


See

http://msdn.microsoft.com/library/d...html/65c7c792-d3d3-4c3b-977a-2b499137b3f7.asp

"To call a Sub procedure from another procedure, type the name of the
procedure along with values for any required arguments, each separated by a
comma. The Call statement is not required, but if you do use it, you must
enclose any arguments in parentheses.

The following example shows two calls to the MyProc procedure. One uses the
Call statement in the code; the other doesn't. Both do exactly the same
thing. "

Call MyProc(firstarg, secondarg)

MyProc firstarg, secondarg
 
if i put like this...
<a href="#" onclick=Call
"setTextBoxValue('<%#Container.DataItem("SerialNumber")%>')">
<%#Container.DataItem("SerialNumber")%> </a>

return error msg:syntax error
 
What about turning the sub into a function?

<script type="text/vbscript">
function setTextBoxValue(a1,a2)
thedelete.deleteTextBox.value = a1
end function
</script>
 
You have to put all the code inside the onclick property.

<a href="#" onclick="Call
setTextBoxValue('<%#Container.DataItem("SerialNumber")%>')">

or if you use the syntax without paranteses:

<a href="#" onclick="setTextBoxValue
'<%#Container.DataItem("SerialNumber")%>'">

Why are you using VBScript for the client code anyway? You are aware
that it only works in Internet Explorer and no other browsers?
 
Rewrite your code and post it here so that it doesn't use any database
calls, so we can run and test it.

Jeff
 
Back
Top