dongqiao8417
2013-07-16 18:57
浏览 20
已采纳

发布下拉列表的文本而不是PHP中的值

I have this code of a Select in html but i want to send by POST the text.. not the values.. any ideas?? However I do still require the values as well. Thanks in advance!

     <select name="calificaciones" id="calificaciones">
         <option selected value="0"> Elige una opción </option>  
         <option value="1">Demoró en terminar</option> 
         <option value="1">Impuntual</option> 
         <option value="2">Grosero(a) en su trato</option>
         <option value="2">Sucio (a) en su trabajo</option>    
         <option value="4">Dejó inconcluso el trabajo</option> 
         <option value="4">No respetó el precio acordado</option> 
         <option value="8">Fue deshonesto (a)</option> 
         <option value="8">Robó</option> 
     </select>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

  • drflkphi675447 2013-07-16 19:09
    最佳回答

    Use jQuery. Have a look http://jsfiddle.net/whizzzkid/HsKEd/2/

    <select name="calificaciones" id="calificaciones">
             <option selected value="0"> Elige una opción </option>  
             <option value="1">Demoró en terminar</option> 
             <option value="1">Impuntual</option> 
             <option value="2">Grosero(a) en su trato</option>
             <option value="2">Sucio (a) en su trabajo</option>    
             <option value="4">Dejó inconcluso el trabajo</option> 
             <option value="4">No respetó el precio acordado</option> 
             <option value="8">Fue deshonesto (a)</option> 
             <option value="8">Robó</option> 
         </select>
    <div id="output"></div>
    

    As simple as .html() refer to the fiddle

        /*$('option').each(function(){
        $('#output').append($(this).html() + '<br>');
        console.log($(this).html());
    });*/
    
    $('select').bind('change', function(){
        $('#output').html($(this).find(':selected').html() + '<br>');
        console.log($(this).find(':selected').html());
    });
    

    So you can submit the form by jquery after you have their html values. ALSO DO NOT FORGET TO CHECK YOUR BROWSER'S CONSOLE.

    edit 1: even a better code.

    评论
    解决 无用
    打赏 举报
查看更多回答(2条)

相关推荐 更多相似问题