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 Link to comment https://forums.phpfreaks.com/topic/187938-need-help-with-php-get/ 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 Link to comment https://forums.phpfreaks.com/topic/187938-need-help-with-php-get/#findComment-992282 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? Link to comment https://forums.phpfreaks.com/topic/187938-need-help-with-php-get/#findComment-992325 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. Link to comment https://forums.phpfreaks.com/topic/187938-need-help-with-php-get/#findComment-992326 Share on other sites More sharing options...
deansaddigh Posted January 10, 2010 Author Share Posted January 10, 2010 Thanks guys Link to comment https://forums.phpfreaks.com/topic/187938-need-help-with-php-get/#findComment-992327 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 ? Link to comment https://forums.phpfreaks.com/topic/187938-need-help-with-php-get/#findComment-992329 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?? Link to comment https://forums.phpfreaks.com/topic/187938-need-help-with-php-get/#findComment-992330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.