Passing values to next page using anchor tag
One quick question -
I have an anchor tag which on clicking opens a new target window.
I don't want to pass the values either in post or get method.
my html code is like this.
<a class="employee_details" target="_blank" href="index1.php?name=username&id=123">UserName</a>
Is there a way to pass the values to the next page using jquery in a hidden type since there is no submit button. In other words, clicking the anchor tag will redirect to another one page where i should get the name and id and that part should NOT BE VISIBLE ANYWHERE in the url.
Any help Kimz
您可以使用会话变量将值从一个页面传递到另一个页面。
You said that you don't want anything in the url to be shown except from page name so why not using a form with psot method? Post will not show anything in the browser and you won't have to deal with sessions/cookies which require more work.
From documentation
<form method="post" action="index1.php">
<input type="hidden" name="name" value="username" />
<input type="hidden" name="username" value="123" />
<input type="submit" name="submit" value="submit" />
</form>
Now in your second page you just need to retrieve data you need throw variable $_POST['name']
and $_POST['username']
. You can also make your submit button look like a link with some css.
试试这个,这包括一个href标签和onclick调用javascript函数。
<html>
<body>
<form action ="b.php" id="testform" method="post">
<input type="hidden" name="name" value="username" />
<input type="hidden" name="id" value="123" />
</form>
<a class="employee_details" onclick="test()">UserName</a>
<script type="text/javascript">
function test()
{
document.forms.testform.submit();
}
</script>
</body>
</html>
链接地址: http://www.djcxy.com/p/71670.html
上一篇: 使用HTML定位器重定向到URL
下一篇: 使用锚标签将值传递到下一页