PDA

View Full Version : submit button problems


bobginyu
10-20-2004, 06:43 PM
its a .net problem:
I want be able to go to various pages based off the selection. for example they answer yes then yes, the user is directed to pageA. yes, no:pageB etc. How do i go about doing that

Do you like this example?
<select id="example" size="1">
<option selected="selected"> </option>
<option value="yes">yes</option>
<option value="no">no</option>
</select>
<br>
Do you want to continue?
<select id="example2" size="1">
<option selected="selected"> </option>
<option value="yes">yes</option>
<option value="no">no</option>
</select>
<asp:Button id="submit" onclick="usersubmit" runat="server"></asp:Button>

Gamini
10-21-2004, 08:00 AM
You can use a server-side script like php, I can code a script failry easily for a purpose like that. Just tell me what are the options and everything yuo want and I'll see what I can do.

eRad
10-21-2004, 09:47 AM
VB.NET:

<script language="VB" runat="server">
Sub UserSubmit (sender As Object, e As System.EventArgs)

If example1.SelectedItem.Text = "yes" Then
If example2.SelectedItem.Text = "yes" Then
Response.Redirect("pageA.asp")
Else if example2.SelectedItem.Text = "no" Then
Response.Redirect("pageB.asp")
Else If example1.SelectedItem.Text = "no" Then
If example2.SelectedItem.Text = "yes" Then
Response.Redirect("pageC.asp")
Else if example2.SelectedItem.Text = "no" Then
Response.Redirect("pageD.asp")

End Sub
</script>

bobginyu
10-22-2004, 12:04 PM
I tried using the above code but recieved the followong message

BC30081: 'If' must end with a matching 'End If'.
b9f80544dc
so i added an end if and got
BC30451: Name 'example1' is not declared. normally just adding
Sub example1_SelectedIndexChanged(sender As Object, e As EventArgs)

End Sub
works but it didnt

eRad
10-22-2004, 12:24 PM
Well... i just gave it as a quick example

if you actually want working code:

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>

<script language="VB" runat="server">
Sub UserSubmit (sender As Object, e As System.EventArgs)
If example1.SelectedItem.Text = "yes" Then
If example2.SelectedItem.Text = "yes" Then
Response.Redirect("pageA.asp")
Else if example2.SelectedItem.Text = "no" Then
Response.Redirect("pageB.asp")
End if
Else If example1.SelectedItem.Text = "no" Then
If example2.SelectedItem.Text = "yes" Then
Response.Redirect("pageC.asp")
Else if example2.SelectedItem.Text = "no" Then
Response.Redirect("pageD.asp")
End if
End if
End Sub
</script>

</head>
<body>

<form runat='server'>
<asp:dropDownList id="example1" size="1" runat='server'>
<asp:ListItem selected="true"> </asp:ListItem>
<asp:ListItem>yes</asp:ListItem>
<asp:ListItem>no </asp:ListItem>
</asp:dropDownList>

<br><br>

Do you want to continue?

<br><br>

<asp:dropDownList id="example2" size="1" runat='server'>
<asp:ListItem selected="true"> </asp:ListItem>
<asp:ListItem>yes</asp:ListItem>
<asp:ListItem>no </asp:ListItem>
</asp:dropDownList>
<asp:Button id="submit" onclick="usersubmit" runat="server" Text="Go"></asp:Button>

</form>
</body>
</html>

bobginyu
10-22-2004, 05:03 PM
im very new to programming and just figured it worked. Ill try the other thanks