Thursday, March 7, 2013

Redirect a link using button



Below is the example to redirect a link using a button.  We  can also pass checkbox value to the link.
code:
<script type="text/javascript">
<!--
function redirectlink(){
    vc1=document.form1.c1.value;
    vc2=document.form1.c2.value;
    vc3=document.form1.c3.value;
   if (document.form1.c1.checked == false) vc1=0;
   if (document.form1.c2.checked == false) vc2=0;
   if (document.form1.c3.checked == false) vc3=0;
    window.location = "http://jiansenlu.blogspot.com/?c1="+ vc1+"&c2="+vc2+"&c3="+vc3;
}
//-->
</script>
<form action="export.php" method="post"  name="form1">
  <button  type='button' id="filter2"  onclick="redirectlink()"> Redirect a link </button>
    <input type="checkbox"  id="c1"  name="c1" value="1"   />Pass c1
   <input  type="checkbox" id="c2" name="c2" value="1"   />Pass c2
   <input type="checkbox"  id="c3"  name="c3" value="1"   />Pass C3
   </form>

Demo:

Pass c1 Pass c2 Pass C3

1 comment:

  1. hello... can i use this to get the data from an input field and redirect to it on submit?

    ReplyDelete