| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
As an example i want to run a function from a submit button within a form. Here is the code that doesn't work
Code:
<%@LANGUAGE="VBSCRIPT"%>
<% option explicit %>
<%
Function FormGetName()
Dim strName
strName = request.form("txtName")
response.write("strName")
End function
%>
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
-->
</style>
</head>
<body>
<form action="FormGetName()" method="post">
<table width="275" border="1" cellpadding="3" cellspacing="0" bordercolor="#990000">
<tr>
<td width="83" bgcolor="#FFFFCE"><span class="style1">Your Name:</span></td>
<td width="107" bgcolor="#FFFFCE"><input name="txtName" type="text" id="txtName"></td>
</tr>
<tr bgcolor="#FFFFCE">
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>
</body>
</html>
I want to avoid splitting the code onto two seperate ASP pages. Thanks for any help |
|
#2
|
||||
|
||||
|
try this. Let's assume the pages name is page1.asp
Code:
<%
If(Request.Form("Submit") <> "") Then
response.write(Request.Form("txtName"))
End If
%>
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
-->
</style>
</head>
<body>
<form name="form1" method="post" action="test6.asp">
<table width="275" border="1" cellpadding="3" cellspacing="0" bordercolor="#990000">
<tr>
<td width="83" bgcolor="#FFFFCE"><span class="style1">Your Name:</span></td>
<td width="107" bgcolor="#FFFFCE"><input name="txtName" type="text" id="txtName"></td>
</tr>
<tr bgcolor="#FFFFCE">
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>
</body>
</html>
|
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Function from a form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|