[英]html form stopped working after adding javascript
Im working on a PHP application. 我正在开发PHP应用程序。 I had field form changing based on selected value. 我根据选择的值更改了字段形式。 What I want is to change fields depending on privilege. 我要根据权限更改字段。 The form was working before because i had only one type of user now since i have many i've add the script but users can't connect . 该表格以前可以使用,因为我现在只有一种类型的用户,因为我有很多类型,所以我已经添加了脚本,但是用户无法连接。
Here is the code 这是代码
<form action="accueil.php" method="post" name="connect" class="Style6">
<select name="privilege" type="text" id="privilege" class="btn btn-default">
<option value="choix">Choisir privilege</option>
<option value="admin">Administrateur</option>
<option value="client">Client</option>
<option value="agent">Agent</option>
<option value="credit_manager">Credit Manager</option>
<option value="commercial">Commercial</option>
</select>
<div id="admin" class="colors" style="display:none">
<label>Connexion Administrateur </label>
<label>Login</label>
<input name="login" type="text" id="login" class="input-block-level">
<label>Mot de passe<a href="#" class="pull-right"> Mots de passe oublié</a> </label>
<input name="pass" type="password" id="pass" class="input-block-level">
<label>
<button type="button" data-toggle="button" class="btn btn-default" ></button>
Se rappeler de moi</label>
</div>
<div id="agent" class="colors" style="display:none">
<label>Connexion Agent </label>
<label>Login</label>
<input name="login" type="text" id="login" class="input-block-level">
<label>Mot de passe<a href="#" class="pull-right"> Mots de passe oublié</a> </label>
<input name="pass" type="password" id="pass" class="input-block-level">
<label>
<button type="button" data-toggle="button" class="btn btn-default" ></button>
Se rappeler de moi
</label>
</div>
<input type="submit" name="Submit" class="btn btn-default" value="Se Connecter">
</form>
And the jquery code is 而jQuery代码是
$(function() {
$('#privilege').change(function(){
$('.colors').hide();
$('#' + $(this).val()).show();
});
});
The form will submit values regardless of whether the fields are displayed or not. 表单将提交值,无论是否显示字段。 Since you have multiple sets of fields with the same name, I think you might be overriding what you think you're submitting with blank values. 由于您有多个具有相同名称的字段集,因此我认为您可能会使用空白值覆盖您认为要提交的字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.