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-
           
jamaicaAsked:
Who is Participating?
 
lakshmisubramCommented:
Does the below code help you ?

<html>
<head>
<script language="JavaScript">
function submitForm()
{
  if (document.test.helpneeded[0].checked)
  {
   

document.test.action="http://www.experts-exchange.com";
  }
  else if (document.test.helpneeded[1].checked)
  {
    document.test.action="http://www.yahoo.com";
  }
}
</script>
</head>
 
<form name="test">
<input type="radio" name="helpneeded" value="yes">yes
<input type="radio" name="helpneeded" value="no">no
<input type="submit" name="submit" value="Submit"

onClick="submitForm();">
</form>
</html>
0
 
lexxwernCommented:
does the form get submitted by POST or GET ?
0
 
lexxwernCommented:
<offtopic>
and have i helped you in the other Q?
</offtopic>
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
lakshmisubramCommented:
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?
0
 
lakshmisubramCommented:
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 ="http://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>
0
 
jamaicaAuthor Commented:
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.
0
 
jamaicaAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.