Home Ask Login Register

Developers Planet

Your answer is one click away!

user3388243 February 2016

How to hide a form input with javascript according to the last chosen option (Radio Buttons)?

How to hide a form input with javascript according to the last chosen option (Radio Buttons)?

Example:

( ) YES ( ) NO

If yes is marked hide the form input and remove a pre-defined value.

If no is marked hide the form input and choose a pre-defined value.

I need to use only javascript..

Answers


Jimmy Canadezo February 2016

Try using onClick with the yes radio button

onclick = "showForm()"

Then add in your document

    <div id = "theform" style="display:none">
<form name = "myform">
..form contents here...
</form>
</div>

<script type = "text/javascript">
function showForm() {
document.getElementById("theform").style.display = "block";
}
</script>

Post Status

Asked in February 2016
Viewed 3,029 times
Voted 7
Answered 1 times

Search




Leave an answer


Quote of the day: live life