Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 更改“公司”文本字段的颜色_Jquery_Html_Css - Fatal编程技术网

Jquery 更改“公司”文本字段的颜色

Jquery 更改“公司”文本字段的颜色,jquery,html,css,Jquery,Html,Css,用户表 user_ID user_type user_company 1 I 用户类型:I-内部E-外部 updateuser.php <html> <head> <link rel="stylesheet" href="js/jquery-ui-themes-1.11.1/themes/smoothness/jquery-ui.css" /> <script ty

用户表

user_ID       user_type       user_company
   1              I                
用户类型:
I-内部
E-外部

updateuser.php

<html>
<head>
<link rel="stylesheet" href="js/jquery-ui-themes-1.11.1/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.11.1/jquery-ui.js"></script>
<script>
$(document).ready(function(){
    //---CLICK USER TYPE RADIO BUTTON---
    $(".usertype").click(function() 
    {
        if($(this).val() === 'I')
        {
            $("#usercompanyname").val('');
            $("#usercompanyname").attr('disabled', true);
            $("#usercompanyname").css("background-color", "gray");
        }
        else 
        {
            $("#usercompanyname").attr('disabled', false);
            $("#usercompanyname").css("background-color", "skyblue");
        }
    });   
});
</script>
<style>
.staffcompanyfieldcellinput {
background-color: skyblue; 
color: blue;
}

.staffcompanydisablefieldcellinput {
background-color: gray; 
color: blue; 
}
</style>
</head>

<body>
<form method="post" action="user.php">
  <table>
  <?php
  //---DB Connect---
  $query = "SELECT *
            FROM user 
            WHERE user_ID = 1"; 
  $result = mysqli_query($dbc, $query);
  $row = mysqli_fetch_array($result);
  ?>
  <tr>
    <td> Type : <span class="style2">*</span></td>
    <td>
      <input type="radio" name="usertype" class="usertype" value="I"
      <?php if($row['user_type'] == 'I') echo 'checked'; ?> />Internal
      <input type="radio" name="usertype" class="usertype" value="E" 
      <?php if($row['user_type'] == 'E') echo 'checked'; ?> />External
    </td>
  </tr>
  <tr>
    <td>Company Name : </td>
    <td>
      <input type="text" name="usercompanyname" id="usercompanyname"   value="<?php echo $row['user_company']; ?>" 
      maxlength="120" size="40" <?php echo ($row['user_type'] == 'I') ? 'class="usercompanydisablefieldcellinput" disabled' : 
      'class="usercompanyfieldcellinput"'; ?> />
    </td>
  </tr>
  <tr>
    <td><input type="submit" name="submit" value="Update User"></td>
    <td><input type="reset" name="reset" value="Reset"></td>
  </tr>
</table>
</form>
</body>
</html>

$(文档).ready(函数(){
//---单击用户类型单选按钮---
$(“.usertype”)。单击(函数()
{
if($(this.val()=='I')
{
$(“#usercompanyname”).val(“”);
$(“#usercompanyname”).attr('disabled',true);
$(“#usercompanyname”).css(“背景色”、“灰色”);
}
其他的
{
$(“#usercompanyname”).attr('disabled',false);
$(“#usercompanyname”).css(“背景色”、“天蓝色”);
}
});   
});
.staffcompanyfieldcellinput{
背景色:天蓝色;
颜色:蓝色;
}
.staffcompanydisablefieldcellinput{
背景颜色:灰色;
颜色:蓝色;
}
类型:*
/>外部的
公司名称:

也许您可以在按reset键时调用javascript函数来修改文本字段和单选按钮