What I want to do is if a user selects “bycrypt”, it should show a field to ask how many passes, and if he/she selects “sha512” to show the same field,but disabled. I was recommended to do this using Jquery,but my attempt is not working.
My code is as follows:
<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; ? >" />
Updated above. Now cuts the page off after the “bycrpt_rounds” label. Does not get to the field for “bycrypt_rounds”.
Something like this: