Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Get another variable

So, I have this script, and it feeds a bunch of variables to the next form.  But due to how the form is layed out, and for a viewer's perspective, we don't ask one variable.  So when the user clicks submit, I route them to another page, and ask them that one question.  Is there a way to do this via javascript or something, so when they click submit, I would pop up the window and get that last variable??

And if so, any way to do any checking (i.e. I'd be looking for a number, so if they put in text, I could just reassert the window or something?)

Thank you.
1 Solution
You can hidden variables which stores users responses with a particular seperator and based on this values in the next page you can do some maipulation.
Hi dougp23,

You can do something like this in javascript, and I will show you an example, but I suggest that you find another way to do this without javascript because javascript is client-side and it can be compleetely disabled by the user.  PHP or ASP, are server-side scripts that will run 100% of the time.  Still, PHP cannot make a popup, so in the end that final question should be attached to that form or something convient, for now here is a javascript example:

<script type="text/javascript">
function askQuestion()
  var input = prompt("Are you scared!? Answer on a 0-10 scale!");
  if (isNaN(input) || input < 0 || input > 10)
    alert("Must be a Number from 1-10!");
    return false;
  document.getElementById("hide").value = input;
  return true;

<h3>Here is a makeshift form, you don't need to do anything but push the submit button!</h3>
Name: <input type="text" name="NAME">
<input type="hidden" name="HIDDEN" id="hide">
<input type="submit" value="submit" onclick="return askQuestion();">

Test it out, it just has a javascript prompt() that asked for a number for 0 to 10 =)
Joe P

Featured Post

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now