Launch Radio     |     Flip Skins

Hiding Querystring Variables in a Form
Sometimes, for whatever reason, we may choose to pass certain variables to a page but hide them out of view by not placing them in the querysting. Often, this may be due to the size or volume of our variables since the QueryString length is limited. If we're using a form, then this is not problem. If we're using a link, however, this will require a bit of clever coding. Keep in mind that the method outlined below in not intended for critical security measures since anyone with basic HTML knowledge and look at your source code and decipher the hidden values in your hidden form.

First, let's create the form that will act as our hidden container.

<form name="HiddenForm" action="NextPage.htm" method="post">
     <input type="hidden" name="HiddenField1" value="xxx">
     <input type="hidden" name="HiddenField2" value="yyy">
</form>

Now let's write a function that submits this form.

<script language="javascript">
     function SubmitHiddenForm()
          {
          document.forms.HiddenForm.submit();
          }
</script>

Finally, we'll trigger our function to fire off when the user clicks on our link.

<a href="#" onClick="SubmitHiddenForm(); return(false);">Click on Me</a>

© 2005 - 2012, MAXO Studio