簡體   English   中英

<input>元素不發布數據?

[英]<input> element does not post data?

我有一個表單頁面,提交此表單時,除以下內容外,所有輸入均已成功過帳:

<input id="TC" class="form-control" name="kullanici_id" type="text" onchange="edit()" 
  <?php if($this->data['kullanici_id']){echo 'readonly';} ?>  
  value="<?php echo $this->data['kullanici_id']?>">

但為什么?

-這是我的.phtml文件:

<html>
<head>

</head>
<body>
<form  enctype="multipart/form-data" action="/admin/kaydet" method="post" onSubmit="javascript: beforeSubmit();">
    <?php if(strlen($this->data['id'])):?>
        <input type="hidden" name="id" value="<?php echo $this->data['id']?>">
    <?php endif;?>
    <font color="green"><h3>DÜZENLE</h3></font>
    <img src="/foto/<?php echo $this->data['fotograf']?>" height="110" width="110" align="left" />
    <table class="table">
        <tr>
            <td>T.C. Kimlik No.:</td>
            <td><input id="TC" class="form-control" name="kullanici_id" type="text" onchange="edit()" <?php if($this->data['kullanici_id']){echo 'readonly';} ?>  value="<?php echo $this->data['kullanici_id']?>"></td>
        </tr>
        <?php if(!strlen($this->data['id'])):?>
        <tr>
            <td>Parola:</td>
            <td><input id="password2" class="form-control" type="password" name="parola" value="<?php echo $this->data['parola']?>"></td>
        </tr>
            <tr>
                <td>Parola Tekrar:</td>
                <td><input onchange="passwordCheck(this.value)" class="form-control" type="password" name="parola" value="<?php echo $this->data['parola']?>"></td>
        </tr>
        <?php endif; ?>
    </table>
    <td><button type="submit" class="btn btn-success btn-sm glyphicon glyphicon-floppy-disk">KAYDET</button> </td>
</form>
</body>
</html>

如果我有身份證; 如果沒有,頁面看起來像是一個編輯成員頁面; 頁面將添加一個新成員。 在id =“ TC”輸入中,如果我編輯成員,則此輸入不應更改,因此我添加了只讀來解決此問題。 但是當我提交時,輸入內容不會發布。 對不起,我的英語不好:D

之所以不提交您的字段,是因為其字段設置為readonly

這樣做的原因是“如果用戶不能更改該字段,則毫無意義,因為值將始終保持不變”。

緩解此行為的一種方法是添加具有相同名稱的隱藏字段

<input type="hidden" name="kullanici_id" value="<?php echo $this->data['kullanici_id']?>"> />
<input id="TC" class="form-control" name="kullanici_id" type="text" onchange="edit()" <?php if($this->data['kullanici_id']){echo 'readonly';} ?>   value="<?php echo $this->data['kullanici_id']?>" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM