2013-12-18 2 views
0

저는 PHP 페이지에있는 폼을 가지고 있습니다. 아래의 세 함수는 이후에 호출됩니다.jQuery 옵션을 반쪽으로 선택했습니다.

달성하고자하는 것은 두 가지 선택이 GET 값을 가져 와서 올바른 값으로 선택한다는 것입니다.

orderType은 정상적으로 작동하지만 orderSel은 작동하지 않습니다. 왜 그리고 이것이 내 문제인지 모르겠다.

여기에 기능을이다 :

function loadOrderButton() 
{ 
    echo "<form name=\"input\" action=\"colview.php\" method=\"get\"> 
     <select onchange=\"this.form.submit()\" class=optionText3 name=\"orderSel\" id=\"orderSel\"> 
      <option class=optionText value=\"\">ORDER BY</option> 
      <option class=optionText value=\"name\">Name</option> 
      <option class=optionText value=\"overall\">Overall</option> 
      <option class=optionText value=\"skt\">Skating</option> 
      <option class=optionText value=\"sht\">Shooting</option> 
      <option class=optionText value=\"hnd\">Hands</option> 
      <option class=optionText value=\"chk\">Checking</option> 
      <option class=optionText value=\"def\">Defense</option> 
      <option class=optionText value=\"faceoff\">Faceoffs</option> 
     </select> 
     <input type=hidden name=\"l\" value=".$_GET[l]."> 
     <input type=hidden name=\"t\" value=".$_GET[t]."> 
     <input type=hidden name=\"orderType\" value=".$_GET[orderType]."> 
     </form>"; 
} 

function loadOrderTypeButton() 
{ 
    echo "<form name=\"input\" action=\"colview.php\" method=\"get\"> 
     <select onchange=\"this.form.submit()\" class=optionText3 name=\"orderType\" id=\"orderType\"> 
      <option class=optionText value=\"DESC\">DESC</option> 
      <option class=optionText value=\"ASC\">ASC</option> 
     </select> 
     <input type=hidden name=\"l\" value=".$_GET[l]."> 
     <input type=hidden name=\"t\" value=".$_GET[t]."> 
     <input type=hidden name=\"order1\" value=".$_GET[orderSel]."> 
     </form>"; 
} 

function setLoadOrder() 
{ 
    echo "<script>  
     var el = jQuery('select#orderSel option[value=\"".$_GET[orderSel]."\"]'); 
     var el = jQuery('select#orderSel option').filter(function(){return jQuery(this).text()==\"".$_GET[orderSel]."\"}); 
     el.attr(\"selected\", \"selected\"); 
     var el = jQuery('select#orderSel option:selected'); 
     el.text(); 

     var el = jQuery('select#orderType option[value=\"".$_GET[orderType]."\"]'); 
     var el = jQuery('select#orderType option').filter(function(){return jQuery(this).text()==\"".$_GET[orderType]."\"}); 
     el.attr(\"selected\", \"selected\"); 
     var el = jQuery('select#orderType option:selected'); 
     el.text(); 
     </script>"; 
} 

도움 주셔서 감사들에 대한 많은.

답변

0

해당 값이 아닌 표시 텍스트를 기준으로 옵션을 필터링하는 경우 orderType의 텍스트와 값이 같기 때문에 (orderSel)이 옵션은 orderType에서 작동합니다.

값을 대신 사용하십시오. 방금의 선택 값으로

jQuery('#orderSel').val(optionValue); 
+0

덕분에 많은 옵션의 가치를 전달할 수 선택한 옵션을 설정하려면

jQuery('#orderSel option').filter(function(){return jQuery(this).val()==\"".$_GET[orderSel]."\"}); 

는 마법처럼 일했다 – injurer001

관련 문제