Solved

Javascript if on hiiden value

Posted on 2009-05-19
3
454 Views
Last Modified: 2012-06-27
I want to run part of a javascript script only if my hidden field's value is set to On.

I am getting an error from Visual Studio because the script is continuing whether the value is On or anything else.

Can you help me?
if (document.getElementById('<%=BlanketHdn.ClientID%>').value = 'On')
                    {
                        var wrapElement = document.getElementById('Blanket');
                        wrapElement.style.position = 'absolute';
                        wrapElement.style.left = '0px';
                        wrapElement.style.width = (windowWidth) + 'px';
                        wrapElement.style.top = '0px';
                        wrapElement.style.height = (windowHeight) + 'px';
                    }

Open in new window

0
Comment
Question by:CatsSolutions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
alien109 earned 500 total points
ID: 24422532
You need a double equals sign for a comparative operation. Right now you are actually doing an assignment and it will always evaluate to true. Try this:
if (document.getElementById('<%=BlanketHdn.ClientID%>').value == 'On')
0
 

Author Closing Comment

by:CatsSolutions
ID: 31583022
I can not believe that I missed that! I feel very stupid now.

Thank you.
0
 
LVL 12

Expert Comment

by:alien109
ID: 24422615
Glad to help. And don't feel stupid - It's so easy to miss a typo in your own stuff and then keep reading how your brain knows it should be, rather than how it really is :) I think we all do that!

Cheers.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question