SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot kryptokid's Avatar
    Join Date
    Nov 2001
    Location
    Brisbane, Australia
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Form Redirect - ASP Related

    Hi, I have the following code (the part in red is what I want to do but don't know the code for):

    <form method="post" action="http://mailgate.server-mail.com/cgi-bin/mailgate" name="helpform">

    <input type="hidden" name="recipient" value="daniel.wahry@det.qld.gov.au">
    <input type="hidden" name="subject" value="Help-Feedback Form">
    <input type="hidden" name="redirect" value="http://www.moreton.tafe.net/thanks.asp?type=(Whatever value is selected in the E-mailSubject select box)">
    <table width="100%">
    <tr>
    <td width="45%">E-mail Subject/td>
    <td width="55%">
    <select name="E-MailSubject">
    <option value="Error Report">Error Report</option>
    <option value="Feedback">Feedback</option>
    <option selected>Please Select...</option>
    </select>
    </td>
    </tr>

    As you can see I want to redirect to a specific page depending on what the user selects. I thought it would have been relatively easy, so I had this post in the Beginner's section but no-one could help me. Has anyone here got any suggestions?

    Thanks
    Daniel

  2. #2
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can run the select box values for a seris of If statments like so:
    [vbs]
    eMailSubject = requst.form("E-MailSubject")
    If eMailSubject = "Error Report" then
    response.redirect("ErrorReport.asp")
    elseIf eMailSubject = "Feedback"
    response.redirect("Feedback.asp")
    else
    response.write("Didn't select a subject!""
    end if
    [/vbs]


  3. #3
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think D's method will work as it'll be the cgi script doing the redirect. I'm not sure how cgi does redirects but if it sends a redirect command to the client, rather than a server side redirect, then the thanks.asp page will have not access to the original form values.

    If this is the case I can see 2 ways of doing this.

    1) A bit of JavaScript that sets the redirect value before submitting the form. The thanks.asp page can use the querystring value as D suggested.

    I've changed the name of the 'E-MailSubject' form element to EmailSubject. You'd also need to add an action for the onsubmit event for the form element, onsubmit="setRedirect();".
    Code:
    <script type="text/javascript">
    
    function setRedirect() {
    	
    	var strUrl;
    	var objRedirect = document.getElementById("redirect");
    	var objBase = document.getElementById("redirect_base");
    	var objEmail = document.getElementById("EmailSubject");
    	
    	if (objRedirect && objBase && objEmail) {		
    		//Build the redirect url
    		strUrl = objBase.value + "?type=" + escape(objEmail.value);
    		//Set the new url
    		objRedirect.value = strUrl;
    	}
    	
    	return true;
    
    }
    
    </script>
    2) Modify the cgi script to determine the page to be redirected to. I've got no experience with cgi so maybe someone else can help with this.

    Edit:
    Forgot to add that you'll need to add another hidden form field 'redirect_base' with the value set to the url of the ASP page that the cgi will redirect to.
    Last edited by shane; Mar 18, 2002 at 08:58.

  4. #4
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whoops, no it won't, wasn't paying attention at all! My bad

  5. #5
    \m/ R.I.P. Dimebag! \m/ JimBolla's Avatar
    Join Date
    Dec 2001
    Location
    erie, pa
    Posts
    1,130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then wouldn't that make this a question for a CGI forum?

  6. #6
    SitePoint Zealot kryptokid's Avatar
    Join Date
    Nov 2001
    Location
    Brisbane, Australia
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help, Shane & DHTMLGod. I'll try the suggestions out.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •