Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How can I disable php combobox's default option?
Old 01-27-2007, 11:04 AM How can I disable php combobox's default option?
Average Talker

Posts: 20
Name: Chris
Trades: 0
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 anywhere.

Here's the code that's at work (as far as I can tell):
Code:
<?php
class 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))) ? '&nbsp;&nbsp;' : '';
            $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);
?>
The combo box itself is called onto the page with a very simple PHP code specifying the listComicSelectBox function.

Thanks for your help everyone!
toastysquirrel is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-29-2007, 05:07 AM Re: How can I disable php combobox's default option?
Novice Talker

Posts: 8
Name: Matt
Trades: 0
<?php
class 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="if (value!=\"\") {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))) ? '&nbsp;&nbsp;' : '';
$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);
?>
Devourer09 is offline
Reply With Quote
View Public Profile
 
Old 01-29-2007, 11:17 AM Re: How can I disable php combobox's default option?
Average Talker

Posts: 20
Name: Chris
Trades: 0
Awesome, worked like a champ!

Mucho thanks
toastysquirrel is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How can I disable php combobox's default option?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22368 seconds with 12 queries