Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2002-07-03
7
Medium Priority
?
242 Views
Last Modified: 2010-03-05
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-
           
0
Comment
Question by:jamaica
  • 3
  • 2
  • 2
7 Comments
 
LVL 12

Expert Comment

by:lexxwern
ID: 7127267
does the form get submitted by POST or GET ?
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 7127276
<offtopic>
and have i helped you in the other Q?
</offtopic>
0
 

Expert Comment

by:lakshmisubram
ID: 7127332
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:lakshmisubram
ID: 7127361
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
 

Author Comment

by:jamaica
ID: 7127457
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
 

Accepted Solution

by:
lakshmisubram earned 400 total points
ID: 7144125
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
 

Author Comment

by:jamaica
ID: 7146985
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question