私がやりたいことは、ユーザーが「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」のフィールドに到達しません。