Solved

Get the attribute value of a hidden field?

Posted on 2011-09-29
4
323 Views
Last Modified: 2012-05-12
<input type="hidden" name="showonlyinstorepickup" value="false" />

My alert box comes up as undefined instead of what the attribute is set to:

 if ($('input[name="showonlyinstorepickup"]').length > 0)
        {
            alert($(this).attr("name"));
        }

I am actually more interested in what the value attribute is set to instead of what the name attribute of the hidden field is.

   alert($(this).attr("value"));

also says "undefined"



NOTE:  If there is a better way to put information on the page that is hidden, please let me know....I am open to a better way of doing this.
0
Comment
Question by:knowlton
  • 2
4 Comments
 
LVL 15

Assisted Solution

by:Eyal
Eyal earned 100 total points
ID: 36817818
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36817821
if ($('input[name="showonlyinstorepickup"]').length > 0)
        {
            alert($('input[name="showonlyinstorepickup"]').attr("name"));
        }

or

$h = $('input[name="showonlyinstorepickup"]');
if($h.length > 0)
{
    alert($h.attr("name"));
}
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 36817826
to display the val :

$h = $('input[name="showonlyinstorepickup"]');
if($h.length > 0)
{
    alert($h.val());
    //alert($h.attr("value"));
}
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 36893324
thx
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now