如何在选择框中获取所选选项的值

时间:2017-12-29 18:45:46

标签: jquery twitter-bootstrap

我想显示一个选中该选项的提醒但我无法看到我的表单的弹出式提醒。

这是我的php:

<select class="form-control" id="status_users">
  <option>All</option>
  <option>Active</option>
  <option>Inactive</option>
  <option>Try</option>
</select>

这是我的剧本:

$(function SelectStatus(){
   $('#status_users').change(function () {
      var selectedText = $(this).find("option:selected").text();
      alert(selected);
   });
});

怎么了?谢谢!

2 个答案:

答案 0 :(得分:1)

1.jQuery库需要在脚本代码之前添加。

2. <?php // Del First Char function trimit( $string ) { return substr( $string, 1 ); } // Ini the line count $linecount = 0; // Open File by Line $handle = fopen("users.txt", "r+"); if ($handle) { // Read line while (($line = fgets($handle)) !== false) { // Trim line to time $alt = strstr($line, '='); $alt = trimit($alt); // IF line is older than 10 minutes, clear it if (time()-600 > $alt) { $newcount = 0; $fp = fopen("users.txt", "w+"); while (($line2 = fgets($fp)) !== false) { if ($newcount === $linecount) { fwrite($fp, $line2); echo "worked"; } $newcount++; } fclose($fp); } $linecount++; } fclose($handle); } else { echo "FATAL ERROR: Could not read file"; } ?> 需要$(function SelectStatus(){

3. $(function(){需要alert(selected);

工作代码段: -

&#13;
&#13;
alert(selectedText);
&#13;
$(function(){
  $('#status_users').change(function(){
    var selectedText = $(this).find("option:selected").text();
    alert(selectedText);
  });
});
&#13;
&#13;
&#13;

答案 1 :(得分:1)

像这样使用,

  b_value = (double)gGte_b_993EDA * light_colour_matrix_3 * 0.00390625;
  if ( never_written_v7 )
  {
    gGte_RGB2_993F18.r = 0;
  }
相关问题