0

私がやりたいことは、ユーザーが「bycrypt」を選択した場合、パスの数を尋ねるフィールドを表示し、「sha512」を選択して同じフィールドを表示するが無効になっている場合です。Jqueryを使用してこれを行うことをお勧めしましたが、私の試みはうまくいきません。私のコードは次のとおりです。

    <fieldset>
    <legend>Security</legend>
    <label>Hash Type</label>
    <select name="hash" id="myId">
            <option value="bcrypt"<?php if($hash == 'bcrypt') { echo ' selected="selected"'; } ?>>Bcrypt</option>
            <option value="sha512"<?php if($hash == 'sha512') { echo ' selected="selected"'; } ?>>SHA512</option>
        </select>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js" /></script>
    <label>Bcrypt rounds <i>(12 Rounds is recommended)</i></label>
    <script type="text/javascript>
    $("#myId").change(function() {
var tst = document.getElementById('myId').value;

if (tst ==1) {
    document.getElementById('#bcrypt_rounds').disabled=true;
} else {
    document.getElementById('#bcrypt_rounds').disabled=false;
}
});

    </script>
<input name="bcrypt_rounds" id="bcrypt_rounds" type="text" value="<?php echo $bcrypt_rounds; ?       >" />  

上記を更新しました。「bycrpt_rounds」ラベルの後にページを切り取るようになりました。「bycrypt_rounds」のフィールドに到達しません。

4

3 に答える 3

0

このようなもの:

<script type="text/javascript">
$("#myId").change(function() {
    var tst = document.getElementById('myId').value;

    if(tst == "sha512") {
        document.getElementById('number_field_id').disabled=true;
    } else {
        document.getElementById('number_field_id').disabled=false;
    }
});
</script>
于 2012-09-07T13:02:22.273 に答える
0

これでいいと思います

$("#myId").change(function() { 
    if($(this).val() == 'sha512'){
      $('#textBxId').attr({'disabled','disabled'});
    }else{
      $('#textBxId').removeAttr({'disabled'});
    }
});
于 2012-09-07T13:07:43.233 に答える
0

エラーを見つけてください"<script type="text/javascript">

<fieldset>
    <legend>Security</legend>
    <label>Hash Type</label>
    <select name="hash" id="myId">
            <option value="bcrypt"<?php if($hash == 'bcrypt') { echo ' selected="selected"'; } ?>>Bcrypt</option>
            <option value="sha512"<?php if($hash == 'sha512') { echo ' selected="selected"'; } ?>>SHA512</option>
        </select>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js" /></script>
    <label>Bcrypt rounds <i>(12 Rounds is recommended)</i></label>
    <script type="text/javascript">
    $("#myId").change(function() {
var tst = $('myId').val();

if (tst ==1) {
    $('#bcrypt_rounds').attr('disabled','disabled');
} else {
    $('#bcrypt_rounds').removeAttr('disabled');
}
});

    </script>
<input name="bcrypt_rounds" id="bcrypt_rounds" type="text" value="<?php echo $bcrypt_rounds; ?       >" />  
于 2012-09-07T13:08:43.053 に答える