Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP NEWBIE Calling Functions in Textbox

Status
Not open for further replies.

gomirage

Programmer
Jun 3, 2003
28
US
Hello everyone,

Can anyone help me on how to call the results of a computation in a text box. For example i want to do

<% function doMycomputation()
Compute =5*6
end function
%>

<FORM action=&quot;asptutorial.asp&quot; method=POST id=form1 name=form1>
<br> Results <INPUT type=&quot;text&quot; id=TxtHf name=TxtHf value=<%=doMycomputation%>> <br>

<INPUT type=&quot;submit&quot; value=&quot; Compute &quot; id=submit1 name=submit1>
</form>


I don't know why it is not working. But i am suspecting when the server compute the function once it is over, it is not possible to call it again. Any help ?

Thank you very much
 
Your function doesn't return anything, so there's nothing for it to print. To return something from a function you need to set the name of the function to the thing you want to return. For example, your function could be written like this:
Code:
<%
Function doMycomputation()
    doMycomputation = 5 * 6
End Function
%>
There is no such thing as &quot;Compute&quot; in ASP that I'm aware of.
 
Ah, I see, you were using &quot;Compute&quot; as a variable. If you wanted to you could write your function like this (but understand that the &quot;Compute&quot; variable has nothing to do with your form at all -- it's just a name):
Code:
<%
Function doMycomputation()
    Compute = 5 * 6
    doMycomputation = Compute
End Function
%>
 
HEY Genimuse,
Thank you for your reply. I realize it also and corrected it. The problem is that it is calling the function when the page load instead of when clicking the submit button.
Do you know how to control the event?
thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top