I have a Wufoo form that I wanted to populate one of the fields with a value directly from the query string
alt text http://www.balexandre.com/temp/2010-07-26_2057.png
the normal jQuery call for this does not get anything back
jQuery("#Field13")
so, all set using this, is just not accomplish
jQuery("#Field13").val( my_qs_value );
alt text http://cl.ly/1n5W/content
I'm using the Embed Javascript code from Wufoo (not the iframe), and the free account, I'm also using jQuery and not the dollar sign for calling the jQuery methods.
Any idea in what can I try? Or is there a setup that can place this by default?
Edited
From Chris answer I got everything to work, in the Wufoo javascript code I added the defaultValues
parameter that would call a method returning the information I needed.
'defaultValues':'Field13=' + getQuerystring('pname',''),
and the getQuerystring method I took it from Blogging Developer site:
function getQuerystring(key, default_)
{
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
if(qs == null)
return default_;
else
return qs[1];
}
We can't access the Wufoo iFrame as it's wufoo domain and all tries will end up with a cross-domain error call. This is the best solution and the Wufoo way of doing it.
Check out our documentation on URL modifications for prefilling Wufoo forms: http://wufoo.com/docs/url-modifications/
Basically in the JavaScript embed code, you can pass an additional parameter to prefill fields: 'defaultValues':'field5=wufoo&field6=today'
It looks like in your case you'll need to pull them out of the URL using whatever server side technology you are using to serve the page, then popular the JavaScript parameters with that data.
The reason that jQuery can't get at the fields inside is because the form is inside an iFrame (even with the JavaScript embed method) and JavaScript can't look inside iframes like that. Also, the screenshot has jQuery("Field13"), which would need to be jQuery("#Field13") as you have in the text above, if the form was actually on the same page.