[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Get the attribute value of a hidden field?

Posted on 2011-09-29
4
Medium Priority
?
331 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:Tom Knowlton
[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
4 Comments
 
LVL 15

Assisted Solution

by:Eyal
Eyal earned 400 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 1600 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:Tom Knowlton
ID: 36893324
thx
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
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)

649 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