使用多个JavaScript Onload函数
Using Multiple JavaScript Onload Functions
我想在我的网站上为两个特定用户提供两个Onload功能。然而,当我添加第二个OnLoad功能时,单选按钮被禁用,我无法使用它们,有什么想法吗?
$(window).on('load', function () {
if (frmUser.User.value != 'SYSTEM') {
frmUser.textCustomer.style.backgroundColor = '#cccccc';
frmUser.textCustomer.disabled = true;
frmUser.textSiteCode.style.backgroundColor = '#cccccc';
frmUser.textSiteCode.disabled = true;
frmUser.option.disabled = true;
frmUser.radioadd.disabled = true;
frmUser.radiodelete.disabled = true;
}
});
$(window).on('load', function () {
if (frmUser.User.value != 'TRAINER') {
frmUser.textCustomer.style.backgroundColor = '#cccccc';
frmUser.textCustomer.disabled = true;
frmUser.textSiteCode.style.backgroundColor = '#cccccc';
frmUser.textSiteCode.disabled = true;
frmUser.option.disabled = true;
frmUser.radioadd.disabled = true;
frmUser.radiodelete.disabled = true;
}
});
这是页面其余部分的代码
<asp:Literal ID="litLoginActionHidden" runat="server" />
<div>
<table>
<tr>
<td style="height: 21px">
<asp:Literal ID="errormsg" runat="server"/>
</td>
</tr>
</table>
</div>
<form id="frmUser" method="post" action="/Stock/UserMaint?action=update">
<div class="screentitle">
<asp:Literal ID="screentitle" runat="server"/>
</div>
<div>
<table>
<tr>
<td>
<asp:HyperLink ID="linkBack" Text=" Back" runat="server" ToolTip="Back" class="ApplicationDefault" ><img class="ApplicationDefault" alt="Back" src="../../Images/external.png" /></asp:HyperLink>
</td>
<td>
</td>
<td>
<asp:image ID="Image1" runat="server" src="../../Images/save.png" ToolTip="Save" onclick="return SubmitForm()" />
</td>
<td style="width: 99%; text-align: right">
<asp:HyperLink ID="linkBackToMainPage" ToolTip="Log Out" runat="server" class="ApplicationDefault" ><img class="ApplicationDefault" alt="Log out" src="../../Images/door_out.png" /></asp:HyperLink>
</td>
</tr>
</table>
</div>
<div class='FixedDiv' style="text-align: center; height: 179px;" >
<asp:HyperLink ID="linkLogin"
Text=" " runat="server" />
<table cellspacing="5px" cellpadding="0px" style="text-align: center; margin-left:auto; margin-right:auto;" >
<!-- row 1 -->
<tr class='FixedDiv'>
<td style="width: 65%; height: 124px;"> <!-- left box -->
<table>
<tr class='FixedDiv'>
<td style="width: 20%; height: 15px;"></td>
<td align = 'left' style="width: 20%; height: 15px;">
<input id="radioupdate" type="radio" name="option" value="Update" onselect="setUpdateActive()" onclick="setUpdateActive()" checked="checked" /> Update</td>
<td align = 'left' style="width: 20%; height: 15px;">
<input id="radioadd" type="radio" name="option" value="Add" onselect="setAddActive()" onclick="setAddActive()" /> Add</td>
<td align = 'left' style="width: 20%; height: 15px;">
<input id="radiodelete" type="radio" name="option" value="Add" onselect="setDeleteActive()" onclick="setDeleteActive()" /> Delete</td>
<td style="width: 20%; height: 15px;"></td>
</tr>
<tr class='FixedDiv'>
<td align = 'left' style="width: 20%; height: 15px;">
User:</td>
<td align = 'left' style="width: 20%; height: 15px;">
<asp:Literal id="litUserMaint" runat="server" />
</td>
<td style="width: 20%; height: 15px;"></td>
<td align = 'left' style="width: 20%; height: 15px;">
New User:</td>
<td align = 'left' style="width: 20%; height: 15px;">
<input disabled="disabled" style="background-color: #cccccc; width: 151px; height: 15px;" type="text" id="textNewUser" name="textNewUser" />
</td>
</tr>
<tr class='FixedDiv'>
<td align = 'left' style="width: 20%; height: 15px">
Password:
</td>
<td align = 'left' style="width: 20%; height: 15px">
<asp:Literal id="litUserPwd1" runat="server" />
</td>
<td style="width: 20%; height: 15px;"></td>
<td align = 'left' style="width: 20%; height: 15px">
Confirm Password:
</td>
<td align = 'left' style="width: 20%; height: 15px">
<asp:Literal id="litUserPwd2" runat="server" />
</td>
</tr>
<tr class='FixedDiv'>
<td align = 'left' style="width: 20%; height: 23px">
Country:
</td>
<td align = 'left' style="width: 20%; height: 23px">
<asp:Literal id="litCountryList" runat="server" />
</td>
<td style="width: 20%; height: 23px;"></td>
<td align = 'left' style="width: 20%; height: 23px">
Email Address:</td>
<td align = 'left' style="width: 20%; height: 23px">
<asp:Literal id="textEmail" runat="server" />
</td>
</tr>
<tr>
<td align = 'left' style="width: 20%; height: 23px">
Customer Code:
</td>
<td align = 'left' style="width: 20%; height: 23px">
<asp:Literal id="litCustomerCode" runat="server" />
</td>
<td>
</td>
<td align = 'left' style="width: 20%; height: 23px">
SiteCode:
</td>
<td align = 'left' style="width: 20%; height: 23px">
<asp:Literal id="litSiteCode" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
<!-- row 1 -->
</table>
</div>
</form>
if (frmUser.User.value != 'SYSTEM' || frmUser.User.value != 'TRAINER') {
frmUser.textCustomer.style.backgroundColor = '#cccccc';
frmUser.textCustomer.disabled = true;
frmUser.textSiteCode.style.backgroundColor = '#cccccc';
frmUser.textSiteCode.disabled = true;
frmUser.option.disabled = true;
frmUser.radioadd.disabled = true;
frmUser.radiodelete.disabled = true;
}
$(window).on('load', function () {
if (frmUser.User.value != 'SYSTEM' && !'TRAINER' || frmUser.User.value != 'TRAINER' && !'SYSTEM') {
frmUser.textCustomer.style.backgroundColor = '#cccccc';
frmUser.textCustomer.disabled = true;
frmUser.textSiteCode.style.backgroundColor = '#cccccc';
frmUser.textSiteCode.disabled = true;
frmUser.option.disabled = true;
frmUser.radioadd.disabled = true;
frmUser.radiodelete.disabled = true;
}
});
这使它工作
相关文章:
- 在phonegap中为android调用onload函数的最佳方式
- 如何调用表td标记内的Onload函数
- 不执行包含的页面的Javascript onload函数
- 你能停止window.onload函数吗
- 使用多个JavaScript Onload函数
- 如何只使用一次window.onload函数
- 在iframe中禁用onload函数的Javascript
- 如果可能的话,使用jQuery onLoad函数来加载特定的页面
- 将Window Onload函数转换为非阻塞
- JavaScript-如何将onload函数内部定义的变量取到外部
- 为什么window.onload函数未定义
- 特定窗口的onload函数
- 如何同时创建两个Onload函数
- onLoad函数不工作,如何使用BindListener修复它
- javascript onload函数范围查询
- javascript onload函数有效,onresize则无效
- Image.onload 函数为高度和宽度返回零
- 全局传递xhr onload函数的值
- 尽管有onload函数,但替换内部HTML失败
- windows.onload函数不工作