ldonop Posted May 4, 2020 Share Posted May 4, 2020 (edited) translate my code please; javascript to php. very very very very thanks. <form> <input type="checkbox" name="myfilter" value="+abst">Amytag1 <input type="checkbox" name="myfilter" value="+mini">Amytag8 <input type="checkbox" name="myfilter" value="+popa">Amytag9 <input type="checkbox" name="myfilter" value="+impr">Amytag13 <input type="checkbox" name="myfilter" value="+green">Amytag15 <input type="checkbox" name="myfilter" value="+gh5">Amytag18 <input type="checkbox" name="myfilter" value="+gh4">Amytag19 <input type="checkbox" name="myfilter" value="+gh3">Amytag34 <input id="search1" placeholder="Word Search..." value=""> <input id="year1" placeholder="Year" value=""> <input id="month1" placeholder="Month" value=""> <input id="day1" placeholder="Day" value=""> <input id="mymenu" value=""> </form> <button onclick="myFunction()" class="Sbutton">search it</button> <script> function myFunction() { var myfilter = document.forms[0]; var txt = ""; var i; for (i = 0; i < myfilter.length; i++) { if (myfilter[i].checked) { txt = txt + myfilter[i].value; } var year = "&year=" + document.getElementById("year1").value; var month = "&month=" + document.getElementById("month1").value; var day = "&day=" + document.getElementById("day1").value; var search = "&s=" + document.getElementById("search1").value; var tag = "/?tag=" + document.getElementById("mymenu").value; } var zzz = "http://test.com/category/art" + txt + tag + year + month + day + search; window.location.assign(zzz) } </script> and please, not use this way: header("Location: {$target}"); exit; Because it doesn't work on my site (for some reason). p.s: I have a lot of checkbox. Edited May 4, 2020 by ldonop Quote Link to comment https://forums.phpfreaks.com/topic/310690-translate-my-code-please-javascript-to-php/ Share on other sites More sharing options...
chhorn Posted May 4, 2020 Share Posted May 4, 2020 Maybe you read the FAQ of this forum first: Quote Link to comment https://forums.phpfreaks.com/topic/310690-translate-my-code-please-javascript-to-php/#findComment-1577518 Share on other sites More sharing options...
ldonop Posted May 4, 2020 Author Share Posted May 4, 2020 31 minutes ago, chhorn said: Maybe you read the FAQ of this forum first: ok. just guide me. Quote Link to comment https://forums.phpfreaks.com/topic/310690-translate-my-code-please-javascript-to-php/#findComment-1577519 Share on other sites More sharing options...
kicken Posted May 4, 2020 Share Posted May 4, 2020 Make it so you can submit your form data to a script. Read your form data in the script using $_GET or $_POST depending on your form method. Create your query string from the form data. Concatenate the query string to your base URL. Issue your redirect to the new location. 1 Quote Link to comment https://forums.phpfreaks.com/topic/310690-translate-my-code-please-javascript-to-php/#findComment-1577525 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.