Reputation: 749
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
Upvotes: 2
Views: 16291
Reputation: 23480
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
- POST requests are never cached
- POST requests do not remain in the browser history
- POST requests cannot be bookmarked
- POST requests have no restrictions on data length
<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.
Upvotes: 2
Reputation: 686
Try this, this includes a href tag and onclick does call javascript function.
<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>
Upvotes: 0
Reputation: 592
You can use the session variable to pass the value from one page to another page.
Upvotes: 1