开发者

XHTML: No selected item in <select> despite of 'selected="selected"'

I'm making a XHTML Page, and i'm using php to generate it. So, now I'm generating a combobox like this:

<select id="Indexer_Backend_select" size="1" onchange="changeHidBySelect('all_id')">
    <option value="nr1">nr1</option>
    <option value="nr2">nr2</option>
    <option value="nr3" selected="selected">nr3</option>
</select>

So, now, in some cases, it's working, and in some othere cases, there is just the toppest selected.

Why this? I'm seriously blockd, so I don't know at all how to go on...

thx for help

EDIT:

-I'm using Firefox

-I just wrote this everywhere, it gets generated by a PHP function which looks like this:

function createOptions($defaultvalue,$curr_path,$default_important,$only_modules) {

###############################################################################################
## String createOptions($defaultvalue string, $curr_path string, $default_important boolean, ##
##                      $only_modules boolean);                                              ##
##                                                                                           ##
## This function returns all the Modules which can be selected in every workflow.            ##
## The Return value is a string (the HTML-Code for the <select>-Wheel)                       ##
##                                                                                           ##
## $defaultvalue describes the preselected value. If none is set, the toppest (alphabetic    ##
## order) is selected. For more, read param $default_important...                            ##
##                                                                                           ##
## $curr_path describes the path, on which the select's ID is based.                         ##
##                                                                                           ##
## $default_important describes, if it is important to recognize, if no default-value was    ##
## given. If true, every time, no default-value was given, a little star is displayed        ##
## next to the <select>. If false, this won't be displayed.                                  ##
##                                                                                           ##
## $only_modules says, if the complete select tag or only all the <option>-Entrys should be  ##
## returned. So, if set to true, only a list of <option>-Tags will be returned.              ##
###############################################################################################
//Get global var $config... In there are the names for the options
global $config;
//Calling Global Array $config...
$options = $config["Indexer"]["Modules"]; //In here are the diffrent options
//Now creating options wheel...
$options_wheel = "";
if (!$only_modules) {
    $options_wheel = "<select id=\"" . $curr_path . "_select\" size=\"1\" onchange=\"changeHidBySelect('" . $curr_path . "')\">";
}
$default_set = 0;
foreach ($options as $key => $value) {


    $options_wheel .= "<option value=\"" . $options[$key]["Class"] . "\"";
    if ($options[$key]["Class"] == $defaultvalue) { //in $options[$key]["Class"] are the values saved, e.g. "nr2"
        $options_wheel .= " selected=\"selected\"";
        $default_set = 1;
    }
    $options_wheel .= ">" . $options[$key]["Class"] . "<";
    $options_wheel .= ($only_modules ? "\\" : "");
    $options_wheel .= "/option>";        

} 
if (!$only_modules) {
    $options_wheel = $options_wheel . "
    </select><input type=\"hidden\" id=\"" . $curr_path . "_hidvalue\" name=\"" . $curr_path . "_hidvalue\" value=\"" . $defaultvalue . "\" />
    ";
}
if (($default_set == 0)&&($default_important == true)) {
    $options_wheel .= "*";
} 
return $options_wheel;

}

And if I call this function now, I call it like this:

echo createOptions($value4,$options_path,true,false); 

$value4 is the defaultvalue, for upper example this would be "nr1"

So, and if I watch the code now with firebug or as source, there is sometimes a selected="selected" which works, but in other cases there is one which simply not works, and the first开发者_StackOverflow element is shown.


So guys, another question self-solved within one hour while posting. I just found why:

I'm calling after all displaying a JS function, which manipulates a div next to this div with the select in it, and it seem to change it somehow. So but now if I disabled this function, it worked perfectly. So I'll edit this function now ;) thx for help

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜