Link to home
Start Free TrialLog in
Avatar of jamaica
jamaica

asked on

Using 2 diff response page to load based on form object selection

Currently my perl script goes to one response/return page after the user submits the form data input. The path to the page is coded as $html_path="/usr/local/myserverhtml/response.html

Within the form's html form object are two radio buttons
 <input type="radio" value="yes" name="helpneeded">
 <input type="radio" value="no" name="helpneeded">

What I'm trying to accomplish is to have the user get a return page that corresponds with whichever of the radio button he selected on the form, e.g., if user selects "NO" for "helpneeded" then he gets to the helpneeded.html page after he submits the form results.

I tried embedding a javascript and used the return/response html pages as values but that would be incorrect, since I want the values to be retained as either "YES|NO"

Can anyone help me with this please?
Thanks.
-jamaica-
           
Avatar of lexxwern
lexxwern
Flag of Netherlands image

does the form get submitted by POST or GET ?
<offtopic>
and have i helped you in the other Q?
</offtopic>
Avatar of lakshmisubram
lakshmisubram

after choosing the radio button do you want to throw different html pages based on the chosen radio buttons ?
can you explain in detail more?
Depending on form object selection , you want to load different pages . right ? This is the thing you need to do ?

<html>
<head>
<script language="JavaScript">
function submitForm()
{
   if (document.test.helpneeded[0].checked)
   {
     window.location ="https://www.experts-exchange.com";
   }
   else if (document.test.helpneeded[1].checked)
   {
     window.location ="http://www.yahoo.com";
   }
}
</script>
</head>
   
<form name="test">
<input type="radio" name="helpneeded" value="yes" onClick="submitForm();">yes
<input type="radio" name="helpneeded" value="no" onClick="submitForm();">no
</form>
</html>
Avatar of jamaica

ASKER

lexxwern, the form uses POST and yes you have helped me with one QID :)

lakshmisubram, the html page is loaded *when* the user selects the "submit" button but the html page loaded must relate to the radiobutton selection. Therefore onClick wouldn't work.

I'd tried it using the script below in perl but what I get is the actual radiobutton <input value="whatevervalueishere">

<input type="radio" name="response" value="yes_response.html" onclick="document.forms[0].action = this.value" />  YES
<br />
<input type="radio" name="response" value="no_response.html" onclick="document.forms[0].action = this.value" />  NO

I ran into 2 probs with this method above.
#1. The POST method does not work with this ... it didn't work and then when I hit back and resubmitted the form, it worked BUT the value posted in the received email showed as the html page link (i.e., "no_response.html") AND the POST used the $html_path="response.html"

The main focus are ...

a. to get radio button selection to correspond to an html page, whereas, the user selects the SUBMIT button and if the form detected that "NO" was selected then he's sent to "no_response.html"

b. Have the POST read the $html_path for either "no_response.html" or "yes_response.html" based on the radiobutton selection.

If I can't accomplish this then I'll have to figure out how to parse data field entries from form1 to form2 and have form2 POST the form data and send the user to the responding/feedback page.
ASKER CERTIFIED SOLUTION
Avatar of lakshmisubram
lakshmisubram

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jamaica

ASKER

From: lakshmisubram  Date: 07/10/2002 10:40AM PST  

Even though this is not the way I really want it but I have the option of doing it this way...

I'll award you with this, as it better works out what I'm working on. I now have 3 html pages. The first/intro page asks user to select an appropriate radio button "Yes|No".

If user selects Yes, then he's sent to Pg1.html that uses cgi perl post method and encoded return page yes_ret.html

If user selects No, then he's sent to Pg2.html that uses cgi perl, method=post and encoded return page no_ret.html.

Thank you.