is it possible? <SCRIPT LANGUAGE="Javascript"> document.location = "product.php?search=<?php echo $search;?>" </SCRIPT> Code (markup):
passing php variable to JS. try this one <script> function passVariable(var) { document.location = "product.php?search=var" } </script> <body> <form method="POST"> <input type="text" id="variable" name="search"> <input type="submit" value="click me"> </form> </body> HTML: php.... $search = $_POST['search']; echo "<input type=\"hidden\" id=\"variable\" value='" . $search . "' onchange="passVariable($search)">"; PHP: hope this helps
What you have in your first post should work fine as long as the file is parsed as PHP You wont need to pass a variable in.
I think this is what you want (ignore the 2 above "solutions"): <form action="product.php" method="get"> <input type="text" name="search" /> <input type="submit" value="Search" /> </form> Code (markup): When a users submits the form, they will be taken to product.php?search=<search box contents>. Also, this way, it removes the JS requirement.