Forum Moderators: open
I'm new to AJAX to bare with me....
I have a select menu. OnChange I'd like to set a cookie with the value of the select menu.
I'm setting the cookie in a PHP file (if you can set cookies in javascript let me know :)
Here's what I got...
HTML<select name="search_mode" id="search_mode" onchange='aj_file("/ajax/color.php", this.value)'>
<option value="rd">red</option>
<option value="bl">blue</option>
</select>
JAVASCRIPT/AJAX
(At top I'm testing ActiveXObject and setting up xmlhttp... same stuff as everyone else)
function aj_file(serverPage, value) {
xmlhttp.open("GET", serverPage, true);
xmlhttp.send(value);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
return xmlhttp.responseText;
}
}
PHP
$value = $_GET['value'];
setcookie('topsearch', $value, time() + 900000000, "/");
I just want to pass the value to the php file so that I can save it as a cookie. There doesn't have to be a response or confirmation.
Please help! :)