Click to See Complete Forum and Search --> : set form's action in code


BananaQuaalude
12-19-2003, 03:55 PM
Why will this not work? I get an "Object required: 'document' not handled" error.


if Request.Form("txtProjectName") = "" then
document.frmRedirect.action = "Employee/EmployeeView.asp"
else
document.frmRedirect.action = "Project/ProjectView.asp"
end if


Here's the form:

<form name="frmRedirect" method="post" action="">
<input type="hidden" name="cboProjName" value="<%=ProjectID%>">
<input type="hidden" name="txtProjectName" value="<%=strProjectName%>">
<input type="hidden" name="txtUserID" value="<%=dblUserID%>">
<input type="hidden" name="txtEmpID" value="<%=EmpID%>">
</form>


thanks!

slyfox
12-19-2003, 06:48 PM
if Request.Form("txtProjectName") = "" then
Response.Redirect = "Employee/EmployeeView.asp"
else
Response.Redirect = "Project/ProjectView.asp"
end if


ASP is not JavaScript..

BananaQuaalude
12-29-2003, 10:27 AM
I'm not looking for a PHP solution.

VBScript has an 'Action' property that should function as I've coded it below but for some reason is not working.

I'm aware that I could use JavaScript to do this, but it would be easier to make this work.

Also, I don't need to redirect the page. I need to submit the form, so that its values are sent to the page determined by the action property I'm setting.

BananaQuaalude
12-29-2003, 12:44 PM
FYI,this is fixed...

I just added a hidden textbox, populated w/ value of Request.Form("txtProjectName") and read that from JavaScript to determine form's action:

<script language="JavaScript">
if (document.frmRedirect.txtFromURL.value == "") {
document.frmRedirect.action = "Employee/EmployeeView.asp"
} else {
document.frmRedirect.action = "Project/ProjectView.asp"
}
document.frmRedirect.submit()
</script>


And here's the form's hidden text:


<input type="hidden" name="txtFromURL" value="<%=Request.Form("txtProjectName")%>">


Still not sure why the ASP wouldn't work, but this does.