deansaddigh Posted January 10, 2010 Share Posted January 10, 2010 i have a option box that gets filled with dates, but how do i get once the option value has been clicked for example they select 2007 from the drop down, it then posts that value back to the same page. I have this so far but doesnt do anything when clicked. <option value="<?=$this_page.'&year'?>" <? if($_GET{'year'}){echo 'selected';}?>><?=$year?></option> Thank in advance Quote Link to comment Share on other sites More sharing options...
jl5501 Posted January 10, 2010 Share Posted January 10, 2010 Assuming your select is part of a form, and the form is submitted after selection, then if the form is 'post'ed, the value attribute of the selected option will be available after submit, as $_POST['selectname'] where selectname is whatever name you have given the <select> that surrounds the <option>s Best regards John Quote Link to comment Share on other sites More sharing options...
deansaddigh Posted January 10, 2010 Author Share Posted January 10, 2010 How do i get the form to submit though, withought having a submit button, i need it to submit when someone selects a value from the drop down select box? Quote Link to comment Share on other sites More sharing options...
PHP Monkeh Posted January 10, 2010 Share Posted January 10, 2010 You need to do that with JavaScript, as it is client-side rather than server-side. Look in to JavaScript's onChange / onSelect events. Quote Link to comment Share on other sites More sharing options...
deansaddigh Posted January 10, 2010 Author Share Posted January 10, 2010 Thanks guys Quote Link to comment Share on other sites More sharing options...
deansaddigh Posted January 10, 2010 Author Share Posted January 10, 2010 Ok so i found some javascript to do it, but its still not working. <form action="archivedBookings.php" method="get" onchange="this.form.submit(archivedBookings.php);">'; echo '<select name="year" class="dropdown" >'; Is this correct where i have put it ? Quote Link to comment Share on other sites More sharing options...
deansaddigh Posted January 10, 2010 Author Share Posted January 10, 2010 Its ok guys i figured it out with this echo '<select name="year" class="dropdown" onChange="this.form.submit()" >'; Should there be anything in the parenthesis?? Quote Link to comment 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.