having trouble calling a Jquery function from within PHP. I'm getting a syntax error when I'm using the below code:
if(!empty($_POST['selectAGE'])){
$username = $_POST['selectAGE'];
}
if(empty($_POST['selectAGE'])){
echo '<script type="text/javascript">'
, '$("#selectAGE").prepend("<option value=''></option>").val('');'
, '</script>';
}
Am I not escaping properly or something?
further to this, I'm then checking this select box by using
if ( form.selectAGE.selectedIndex == 0 ) { alert ( "Enter the correct Age." ); return false; }
however, once the form has been submitted, it eliminates the prepended 'empty' value and now the one you've selected is selectedindex 0. so the above check returns that you haven't entered it. How can I amend the line above to take this into account?