Hi again, following up my previous post where I was trying to bind a function to a submit event, I'm now trying to pass values from the function that returns a function to the bound submit event.
I've a number of forms on a page, that perform a variety of functions, some similar. I'm trying to create a custom function that posts a checkbox variable, but within the context of the function that returns a function, I can't pass the variables across. If I put an alert(formName); etc, in the postCheckbox function, it confirms the values are being passed across, but alert(document.formName.tagName); , for example, gives 'undefined'. Why does the function not abstract out in this case? Many thanks, Dan. $(document).ready(function(){ initialiseForm("#PollX"); initialiseForm("#PollY"); initialiseForm("#RateX"); }); function initialiseForm(formId) { $(formId).bind('submit', getPost(formId)); } function getPost(formId) { return function() { switch(formId){ case "#PollX": postCheckbox("PollX", "PollXGroup", "div#PollXDiv", " PollXresults.php?PollXRadio=") return false; break; case "#PollY": //do something else return false; break; case "#RateX": // do more things postCheckbox("RateX", "RateXGroup", "div#RateXDiv", " RateXresults.php?RateXRadio=") return false; break; default: return false; } }; } function postCheckbox(formName, radioGroupName, replacementBlock, postURL){ for (var i=0; i < document.formName.radioGroupName.length; i++) { if (document.formName.radioGroupName[i].checked){ var radioValue = document.formName.radioGroupName[i].value; } } if(radioValue){ $(replacementBlock).load(postURL + radioValue).fadeIn("slow"); } } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/