toasty Posted January 27, 2007 Share Posted January 27, 2007 I'm in a bit of a quandary of this small snippet of code I'm trying to modify. It's not my code, by the way :) Anyway, this code works in a combo-box and here's the scenario that's giving me problems.The default value in the box is simply text that outputs "[Archive]". When a user selects one of the valid entries the page is correctly redirect to a dynamic php page with the URL populated by the unique ID of whatever their selection was. However! - and this is the problem - if after making a selection, being redirected to the page the user clicks the back button in the browser taking them back to the page with the combo box; if they make the selection of the "[Archive]" value, they are then redirected to a page (as specified in the code) but with a "blank" ID in the URL.All I want to do is make it so that if the user does click "back" and (un)intentionally selects "[Archive]" they're not redirected [B]anywhere[/B].Here's the code that's at work (as far as I can tell):[code]<?phpclass ccm_archive { var $DB_PREFIX; var $_db; var $_config; var $_common; function ccm_archive($db,$dbConfig,$config,$common) { $this->_db = $db; $this->DB_PREFIX = &$dbConfig->prefix; $this->_config = &$config; $this->_common = $common; } function listComicsSelectBox($showIDs='', $reverse='', $storylines='') { $order = (empty($reverse)) ? 'ASC' : 'DESC'; $result = $this->_db->Execute("SELECT id,date,comic_title,storyline FROM {$this->DB_PREFIX}comic WHERE live='1' ORDER BY date $order"); $r = '<select name="comicID" onchange="location.href=\'' .$this->_config->archive_comic_url."?comicID='+value;\">"; $r .= '<option value="">[Archives]</option>'; while (!$result->EOF) { list ($id,$date,$title,$sl) = $result->fields; $indent = (!empty($storylines) && (!empty($sl))) ? ' ' : ''; $r .= "<option value=\"$id\">"; $r .= (empty($showIDs)) ? "$indent $title" : "$indent [$id] $title"; $r .= "</option>"; $result->MoveNext(); } $r .= '</select>'; return $r; }}$ccm_archive = new ccm_archive(&$ccm_db,&$ccm_dbConfig,&$ccm_config,&$ccm_common);?>[/code]The combo box itself is called onto the page with a very simple PHP code specifying the listComicSelectBox function.Thanks for your help everyone! Quote Link to comment https://forums.phpfreaks.com/topic/35959-how-can-i-disable-php-comboboxs-default-option/ Share on other sites More sharing options...
HuggieBear Posted January 28, 2007 Share Posted January 28, 2007 Do you have this code live anywhere, so we can see what you mean?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/35959-how-can-i-disable-php-comboboxs-default-option/#findComment-171107 Share on other sites More sharing options...
toasty Posted January 28, 2007 Author Share Posted January 28, 2007 [quote author=HuggieBear link=topic=124299.msg515362#msg515362 date=1169988699]Do you have this code live anywhere, so we can see what you mean?RegardsHuggie[/quote]I definitely realize the benefit of having a place I can showcase the issue at hand. Right now it's in a testing location and I've been sworn to secrecy :P However, I was able to get the code I was looking for to fix the issue at hand.Replacing:[code]$r = '<select name="comicID" onchange="location.href=\'' .$this->_config->archive_comic_url."?comicID='+value;\">";[/code]with:[code]$r = '<select name="comicID" onchange="if(this.value != \'\') location.href=\'' .$this->_config->archive_comic_url."?comicID='+value;\">";[/code]That did the trick :)Thanks for taking an interest in my plea for help Huggie, I definitely appreciate it. :D Quote Link to comment https://forums.phpfreaks.com/topic/35959-how-can-i-disable-php-comboboxs-default-option/#findComment-171214 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.