Created
January 21, 2015 19:01
-
-
Save zulhfreelancer/7f6226786914174d417e to your computer and use it in GitHub Desktop.
Show an Input Field Based On Selected Dropdown And Change a Hidden Input Value Based on That Showed Input Content (if empty and if not empty) // Demo: http://jsfiddle.net/tfntj5ds/
This file contains 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
#ref { | |
display:none; | |
} |
This file contains 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 id="drop"> | |
<option>-- Please select --</option> | |
<option>Agent / Employer</option> | |
<option id="drop_option">Job Seeker</option> | |
</select> | |
<br/> | |
<input name="referral" type="text" placeholder="Referral" id="ref" /> | |
<br/> | |
<input name="check" value="false" type="text" /> |
This file contains 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
$('#drop').change(function () { | |
var selectedId = $('option:selected', this).attr('id'); | |
if (selectedId == "drop_option") { | |
$('#ref').show("slow", "swing"); | |
$("#ref").blur(function () { | |
if ($(this).val() === "") { | |
$('input[name=check]').val('false'); | |
} else { | |
$('input[name=check]').val('true'); | |
} | |
}); | |
} else { | |
$('#ref').hide("slow", "swing"); | |
$('input[name=check]').val('false'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment