Hey guys, sorry i normally browse these forums and have done for a few years but never actually signed up, so.. first post...
I'm having a realllly annoying simple problem. i swear to god i've done this multiple times before but i just cant get it working -
Trying to make a select box auto submit and using PHP to check submission and echo results. I also tried jQuery submission incase it was some JS conflict.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:fb="http://www.facebook.com/2008/fbml" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr">
<head>
<title>Broken Form FTW</title>
<!--script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script-->
<script type="text/javascript">
/* <![CDATA[ */
// JQUERY SUBMISSION, HAS BEEN COMMENTED OUT BECAUSE DOESNT WORK
/*
jQuery(document).ready(function() {
jQuery("form#form_where select").change(function() {
jQuery("form#form_where").submit();
});
});
*/
/* ]]> */
</script>
</head>
<body>
<h1>Broken Form FTW</h1>
<form name="form_where" id="form_where" action="<?php echo $myfull;?>" method="post">
<select name="set" onchange="this.form.submit();" autocomplete="off">
<?php
// IGNORE THIS - JUST GENERATING THE LOCATIONS
$location_array = array('Bodmin', 'Wadebridge', 'St Austell');
$dis = $_COOKIE["locator"];
if (!isset($_COOKIE["locator"])) {
echo '<option value="Cornwall" selected="selected">Cornwall</option>';
} else {
echo '<option value="Cornwall">Cornwall</option>';
}
for($i = 0; $i < count($location_array); $i++) {
$set_which = ($location_array[$i] == $dis) ? 'selected="selected"' : '';
echo '<option value="'.$location_array[$i].'" '.$set_which.'>'.$location_array[$i].'</option>';
}
//
?>
</select>
<noscript><input type="submit" name="submit" id="submit_where" value="Show" /></noscript>
</form>
<?php
// CHECK IF THE VALUE IS SET AND POSTED.. STRANGELY THIS SEEMS TO WORK
if (isset($_POST['set'])) {
$set = $_POST['set'];
echo $set = '1) set - '.$_POST['set'].'<br />';
} else {
echo '1) no set <br />';
}
//if (!empty($_POST['submit'])) {
// CHECK IF SUBMIT IS SET AND ECHO RESPONSE, DOESNT SEEM TO WORK
if (isset($_POST['submit'])) {
echo '2) won like a boss';
} else {
echo '2) failed like a *****';
}
/*
echo '3) Form not empty';
} else {
echo '3) Form empty';
}*/
?>
</body>
</html>
I was putting this together for a little fitler on a Joomla site and stripped it out into a plain HTML doc just to test,and it still doesnt work.. my brain might be melting.
Any help is appreciated, i think i've just been staring at the site for too long but cant work it out...