开发者

Validate form with more links

How I can to do to validate a form contains more links( < a href >) and开发者_StackOverflow this when clicked


Example:

        <form name="form" method="post" action="#">
          <input type="hidden" name="name1" value="val" />
          <input type="hidden" name="name2" value="va2" />
          <input type="hidden" name="name3" value="va3" />
          <a href="url-1"  >Link 1 </a>
          <a href="url-2"  >Link 2 </a>
          <a href="url-3"  >Link 3 </a>
          <a href="url-4"  >Link 4 </a>
        </form>


You need validateform.php script to do validation of post data. Then just use $_POST['redirecturl'] to redirect user. I'm not just experienced with this kind of coding but guess something like this is what you want (if i got your confusing question right).

<html>
<head>
</head>
<body>

<script type="text/javascript">
<!--
function PostAndRedirect(url) {
  document.getElementById('redurl').value=url
  }
-->
</script>

<form name="form" method="post" action="validateform.php">
  <input type="hidden" name="name1" value="val" />
  <input type="hidden" name="name2" value="va2" />
  <input type="hidden" name="name3" value="va3" />
  <input type="hidden" id="redurl" name="redirecturl" value="none" />
  <a href="javascript:PostAndRedirect('url-1')"  >Link 1</a>
  <a href="javascript:PostAndRedirect('url-2')"  >Link 2</a>
  <a href="javascript:PostAndRedirect('url-3')"  >Link 3</a>
  <a href="javascript:PostAndRedirect('url-4')"  >Link 4</a>
</form>

</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜