我尝试将已禁用=“已禁用”

时间:2016-06-20 00:16:33

标签: php html

我有一个选择选项并放置disabled="disabled"以便无法选择,但当我尝试按下更新按钮时,它总是给我这个错误。

  

错误提示:未定义索引:省份   第35行的D:\ wamp \ www \ LTID \ Updaterlbet.php

但是当我尝试删除disabled="disabled"时,它会成功更新。但是,我希望将残疾人放在那里,以便无法选择..

代码

$Province = isset($_GET['fruit']) ? $_GET['fruit'] : '';

if(isset($_POST['update'])){
    $ID = $_GET['ID'];
    $fruit = $_POST['fruit'];
}

HTML

<select name="Province" class="form-control" id="category" onchange="javascript: dynamicdropdown(this.options[this.selectedIndex].value);">
       <option selected="selected" value="<?php echo $fruut; ?>" disabled="disabled"><?php echo $fruit; ?></option>
       <option value="strawberry">strawberry</option>
       <option value="raspberry">raspberry</option>
       <option value="blueberry">blueberry</option>
</select>

2 个答案:

答案 0 :(得分:2)

它将始终抛出错误,因为始终根据您的代码选择禁用选项。要获得此修复,请删除所选属性。

删除:selected="selected"

现在它看起来像这样

<select name="Province" class="form-control" id="category" onchange="javascript: dynamicdropdown(this.options[this.selectedIndex].value);">
       <option value="<?php echo $Province; ?>" disabled="disabled"><?php echo $Province; ?></option>
       <option value="ALBAY">Albay</option>
       <option value="CAMARINES NORTE">Camarines Norte</option>
       <option value="CAMARINES SUR I">blu</option>
</select>

如果要将禁用值选为默认值,请使用此段代码。

<option selected="true" disabled="disabled" <?php echo $Province; ?>><?php echo $Province; ?></option> 

答案 1 :(得分:1)

您的代码中有void Login_Click(object sender, EventArgs e) { string adPath = "LDAP://mydomain.com"; //Path to your LDAP directory server LdapAuthentication adAuth = new LdapAuthentication(adPath); try { if(true == adAuth.IsAuthenticated(txtDomain.Text, txtUsername.Text, txtPassword.Text)) { //string groups = adAuth.GetGroups(); string groups = txtUsername.Text; //Create the ticket, and add the groups. bool isCookiePersistent = chkPersist.Checked; FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, txtUsername.Text,DateTime.Now, DateTime.Now.AddMinutes(60), isCookiePersistent, groups); //Encrypt the ticket. string encryptedTicket = FormsAuthentication.Encrypt(authTicket); //Create a cookie, and then add the encrypted ticket to the cookie as data. HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); if(true == isCookiePersistent) authCookie.Expires = authTicket.Expiration; //Add the cookie to the outgoing cookies collection. Response.Cookies.Add(authCookie); //You can redirect now. Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUsername.Text, false)); } else { errorLabel.Text = "Authentication did not succeed. Check user name and password."; } } catch(Exception ex) { errorLabel.Text = "Error authenticating. " + ex.Message; } } </script>。删除它,它应该工作正常。