Last active
August 24, 2017 03:49
-
-
Save mazfreelance/b992c27c661e4c0fa9cfef015c151b2b to your computer and use it in GitHub Desktop.
JQUERY: hide and show input type="text"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select name="oth" id="oth"> | |
<option value="">Please Select</option> | |
<option value="1">1</option> | |
<option value="2">2</option> | |
</select> | |
<input type="text" id="output" style="display: none"/> | |
$(document).ready(function(){ | |
$("#oth").change(function() { | |
$(this).val() == "2" ? $('#output').show() : $('#output').hide(); | |
}); | |
}); | |
//if want to play with php | |
<select name="oth" id="oth"> | |
<option value="">Please Select</option> | |
<option value="1">1</option> | |
<?php | |
if($detail['1'] == '1'){ // $detail['1'] - retrieve data from dB | |
echo "<script>$(document).ready(function() { $('#output').show();});</script>";} | |
?> | |
<option value="2">2</option> | |
</select> | |
<input type="text" id="output" style="display: none"/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment