Link to home
Start Free TrialLog in
Avatar of leenapedenekar
leenapedenekar

asked on

how to hide the variables values shown in the url which is done in php,javascript

I have a form written in php,html,javascript I pass the value using the javascript href .location and the values can be seen in the url by the user  I want to hide this
Avatar of sandeshj
sandeshj
Flag of India image

Instead of using href.location, create a <form/> with method="post" and action="...the page where you want to go to....", inside the form have the parameters you want using  tag and submit this action on click using javascript.
Avatar of Mehul_Panchal
Mehul_Panchal

you have to pass parrameter in post hidden variable so that it not shown in url.



Thanks
Mehul
ASKER CERTIFIED SOLUTION
Avatar of StealthyDev
StealthyDev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leenapedenekar

ASKER

Some of the data which I take from the user depends upon the selection of the data prior to the some inout boxes eg.batchno select box to be shonly when proudct code is selected and the for the query also the batchno selection query will depend upon the product code selected then in thatb case how do I do it without passing it in the url
You can have multiple hidden fields in the form.

See example:


<form name="myhiddenform" method="post">
<input type="hidden" name="param1" id="param1">
<input type="hidden" name="batchno" id="batchno">
<input type="hidden" name="proudctcode" id="proudctcode">
</form>

<input type="button" onclick="submitForm()" value="submit">

<script>
	function submitForm()
	{
		//window.location = "mypage.php?param1=xyz";
		document.getElementById("param1").value="xyz";
		document.getElementById("batchno").value="abc";
		document.getElementById("proudctcode").value="123";
		document.myhiddenform.action = "mypage.php";
		document.myhiddenform.submit();
	}
</script>

Open in new window

Will try n see if this fits my requirement and get back
sorry for late reply but was cuaght up with something else

But if the value in the second select box depends upon the first input box i.e the first input box value entered is used to query the table on the database server then how do i get it
I dont know your actual Objective, but what is the need for posting values using javascript?

If you are using the <form> tag with POST method. Then nothing to worry. Every HTML Control with an ID specified will be automatically posted the specified target php file.
check
<form name="YourForm" method="post" action="THEDESTINATIONFILE.php">

in THEDESTINATIONFILE.PHP , simply put
if(isset($_POST)){
echo '<pre>';
print_r($_POST);
echo '</pre>';
}
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.