user2917239
user2917239

Reputation: 898

JavaScript hide element function

I have a form where the user can select a generic auto-population based on checking a radio button. When the user checks the auto-populate radio button, the fields are auto populated with the data and then the fields become disabled.

In this first part of the function, I pass the auto-filled data:

            $('#myOptions').click(function()
            $('#value1').val("Auto-filled data");
            $('#Value2').val("Auto-filled data");                
            $('#Value3').val("Auto-filled data");

In this second part, I am disabling the html inputs

            // now i am disabling the html inputs:
            $('#Value4').prop("disabled", true);
            $('#Value5').prop("disabled", true);                
            $('#value6').prop("disabled", true);

Suppose I have another field with an ID of "Value7" in the form, that I would like to hide from the user interface as part of this function.

How can I hide the "Value7" input upon function triggering? I appreciate the help, I am very new to JavaScript, though I find it very exciting!

Upvotes: 1

Views: 160

Answers (3)

Vikram
Vikram

Reputation: 309

I am not getting what are you trying to ask actualy . Let me know if this helps -

$("Value7").hide()

Upvotes: 1

Mr.G
Mr.G

Reputation: 3559

Try this javascript:

if you want disable:

document.getElementById('#Value7').setAttribute("disabled","disabled");

if you want enable:

document.getElementById('#Value7').removeAttribute('disabled');

if you want to hide :

document.getElementById('#Value7').css("display","none");

if you want to show:

document.getElementById('#Value7').css("display","block");

Upvotes: 1

Héctor William
Héctor William

Reputation: 796

Using jquery:

To hide

jQuery('#Value7').hide() or jQuery('#Value7').css("display","none")

To show the element back

jQuery('#Value7').show() or jQuery('#Value7').css("display","block")

or pure js:

javascript hide/show element

Upvotes: 4

Related Questions