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

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...
 
J

JT

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.
 
K

Ken Cox - Microsoft MVP

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
 
Z

zheetee

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

return error msg:syntax error
 
K

Ken Cox - Microsoft MVP

What about turning the sub into a function?

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

=?ISO-8859-1?Q?G=F6ran_Andersson?=

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?
 
J

Jeff Dillon

Rewrite your code and post it here so that it doesn't use any database
calls, so we can run and test it.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top