+ Reply to Thread
Results 1 to 7 of 7

Thread: choice-dependent result URL

  1. #1
    Join Date
    Jan 2005
    Posts
    9

    Default choice-dependent result URL

    Can you tell me if FormMail can do this: collect the values of a user's choices from a web form (via the usual menus, checkboxes, textfields, etc), send those results to certain email addresses, and, send the user to one of several different URLs, dependent on those choices?

    Thanks in advance.

  2. #2
    Join Date
    Dec 2003
    Posts
    3,907

    Default Re: choice-dependent result URL

    Hi,

    If you use JavaScript to make the choices, then you can do just about anything; simply get the JS to set the value the good_url field.

    Most people have JS, so that's not usually a problem and you can detect if JS is missing and do something else (such as show and error message).

    A simple selection is easy without JS.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  3. #3
    Join Date
    Jan 2005
    Posts
    9

    Default Re: choice-dependent result URL

    >If you use JavaScript to make the choices..

    Oh gawd - how do I do that? I've used simple JS function snippets for navigation, but how to use them to set the value of fields in FormMail... (eek!)

  4. #4
    Join Date
    Dec 2003
    Posts
    3,907

    Default Re: choice-dependent result URL

    Hi,

    You should be able to find some code around on the web.

    This will get you started:

    Code:
     
    function OnSubmit(form)
    {
      if (form.somefield.value = "yes")
    	form.good_url.value = "http://www.yoursite.com/theysaidyes.htm";
      return (true);
    }
     
    ...
     
    <form onsubmit="return OnSubmit(this);" ...>
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  5. #5
    Join Date
    Jan 2005
    Posts
    9

    Default Re: choice-dependent result URL

    So you would recommend a combination of JS and php/FormMail for this.. I guess a complete php solution would be more complex and perhaps beyond a (my!) configuration of your FormMail?

    I was hoping to avoid JS completely, since not every browser/device may be able to use it, and because of JS version/browser issues.. but I suppose that the percentage of browsers with no JS is small? I've read that it's as small as 5%, though of course that 5% can include a fair number of visitors, depending on one's target demographic (eg, I remember reading that whole office departments sometimes have JS turned off by default).

    Thanks very much anyway for your advice and help!

  6. #6
    Join Date
    Dec 2003
    Posts
    3,907

    Default Re: choice-dependent result URL

    Hi,

    Currently FormMail has a feature where you can derive fields from other fields. However, this feature doesn't currently allow you to use logic to derive fields - it's a simple concatenation with a set of joining operators.

    To do what you want, you need a program - a set of logical statements and actions.

    So, until FormMail has these features, you need to use other logic. You could write that logic in PHP or JavaScript.

    If you're concerned about JS being switched off then you might be better to write the logic in PHP.

    It's actually pretty easy to link this in with FormMail. Start a file called "submit.php" like this:

    PHP Code:
    <?php
      
    //
      // whatever logic you want to run goes here.  Assuming POST method,
      // you can access fields in the $_POST array and also set them there
      // for FormMail to process when it's included
      //
    if (isset($_POST["somefield"]) && $_POST["somefield"] == "yes")
      
    $_POST["good_url"] = "http://www.yoursite.com/theysaidyes.htm";
     
      
    //
      // Now include FormMail to do all the rest of the work...
      //
    include("formmail.php");
    ?>
    Put it in the same directory as formmail.php and then use submit.php as your form action instead of formmail.php.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  7. #7
    Join Date
    Jan 2005
    Posts
    9

    Default Re: choice-dependent result URL

    I've just had promising results using the mix of FormMail and JS as you suggested.. I don't really program with JS, but I just made it up, and it worked!! (I'm wondering how many conditions I can successfully get into the JS script..) If I could get the results I want using only php I'd be happier, so I look forward to seeing if I can have similar success with this 'extra php' solution! Many many thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Advance Error -no returne URL
    By JohnB in forum FormMail Subscription Support
    Replies: 7
    Last Post: 01-Jan-2005, 11:15 PM
  2. Using formmail from URL bar?
    By Eric Sandres in forum FormMail Subscription Support
    Replies: 1
    Last Post: 05-Nov-2004, 03:52 AM
  3. Now I am stomped! URL for redirect
    By sigurdur in forum FormMail Subscription Support
    Replies: 3
    Last Post: 01-Aug-2004, 01:02 AM
  4. Formmail File Visible In URL Address
    By amazing616 in forum FormMail Subscription Support
    Replies: 5
    Last Post: 03-Jun-2004, 09:13 PM
  5. The requested URL was not found on this server.
    By aussieincanada in forum FormMail Subscription Support
    Replies: 1
    Last Post: 27-May-2004, 08:46 AM

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