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!

1
  • Actually i don't understand what you trying to explain Commented Dec 21, 2013 at 8:30

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, I like how JQuery simplifies it so that I can just call the .hide() method. Thanks a lot.
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");

Comments

1

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

$("Value7").hide()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.