1

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!

yasmuru
  • 1,178
  • 2
  • 20
  • 42
user2917239
  • 898
  • 3
  • 12
  • 27

3 Answers3

4

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

Community
  • 1
  • 1
Héctor William
  • 756
  • 6
  • 24
1

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");
Mr.G
  • 3,413
  • 2
  • 16
  • 20
1

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

$("Value7").hide()

Vikram
  • 309
  • 3
  • 6
  • 19