2010-12-08 95 views
0

我正在製作一個XHTML頁面,並且正在使用php來生成它。所以,現在我生成一個組合框是這樣的:XHTML:<select>中沒有選定的項目,儘管選擇了「selected =」'

<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> 

所以,現在,在某些情況下,它的工作,並在某些情況下othere,還有就是選擇最頂尖的。

這是爲什麼?我很認真地blockd,所以我不知道一切是如何去...

THX的幫助

編輯:

- 我使用的是Firefox

-I剛纔寫的無處不在,它就會通過一個PHP函數,它看起來像這樣產生的:

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; 

}

如果我現在把這個功能,我這樣稱呼它:

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

$ VALUE4是默認值,對上方的例子,這將是「NR1」

所以,如果我看現在的代碼與螢火蟲或來源,有時有選擇=「選定」的作品,但在其他情況下,有一個根本不工作,並顯示第一個元素。

+0

它工作在第一頁的請求或許?你有什麼東西來確定回發,然後做一些不同的結果? – brumScouse 2010-12-08 08:26:30

回答

0

所以,大家,另一個問題在發佈後的一小時內自行解決。我只是找到了原因:

我打電話後顯示一個JS函數,該函數操縱旁邊的div與該選擇的div,它似乎改變它以某種方式。所以現在如果我禁用了這個功能,它就完美了。所以我現在編輯這個功能;)thx尋求幫助