Solved

Firebug says jQuery variable is null, when it is not

Posted on 2012-03-29
4
617 Views
Last Modified: 2012-03-29
I am trying to set up some jQuery to fill in form fields as quantities of things are chosen on a Drupal page. I am following a tutorial to do this. But when I am just trying to see what variables are holding, like:
var a = $('#edit-submitted-users-desktop-users').val();
where edit-submitted-users-desktop-users is the id of a textbox, I get the value is null in Firebug and the Chrome javascript console. I have no idea what I am doing wrong. I usually only use Firebug for CSS issues.
Here is the page I am working on:
http://www.cloudconnect.net/pricing-estimate
0
Comment
Question by:nanharbison
4 Comments
 
LVL 21

Expert Comment

by:Kim Walker
ID: 37784945
Where do you have this script? It has to come after the page has loaded.
0
 
LVL 42

Expert Comment

by:David S.
ID: 37784965
Where are you putting that JavaScript statement?  In the console or in the page? If in the page, where in the page?
0
 
LVL 3

Accepted Solution

by:
nullsquid earned 500 total points
ID: 37785021
for me just typing
$('#edit-submitted-users-desktop-users').val();
(without the 'var a ') into the console returns the value in that field if that is all you want
0
 
LVL 17

Author Comment

by:nanharbison
ID: 37785044
The page has been loaded for hours!
I put this in the command line and got null.
I just put what nullsquid suggested, and that worked. I was just doing what the tutorial said to do. I should always go to experts exchange instead of spending hours trying to figure this out. Other than this, the tutorial is very clear:
http://1013.fi/cms/interactive-drupal-web-forms-jquery-javascript-library
Thanks
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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to count occurrences of each item in an array.

757 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

20 Experts available now in Live!

Get 1:1 Help Now