Reset form with jQuery (part II)

Here I noted how to reset a form with jQuery, however, later I noticed some fields aren’t reset() correctly: in my form I have hidden fields with initial value of “0″ (or just an empty value) and these fields are supposed to be changed interactively upon a user’s input using jQuery. These fields weren’t reset correctly for some reason, at least in Firefox, thus I had to change my original function to something like this:

1
2
3
4
5
function resetForm(id) {
	$('#' + id + ' :input').each(function(){  // I decided not to have different reset routine for different field types
			$(this).val('');
	});
}

Probably less elegant, but works… ;)

How to .reset() form with jQuery

Such jQuery call won’t work:

1
2
	$('#formId').reset();
	// error: $("#formId").reset() is not a function

As the tutorial shows (yes, I never read manuals before I get into troubles as well, but always google answers before think, lol), we can have the following:

1
2
3
4
5
function resetForm(id) {
	$('#'+id).each(function(){
	        this.reset();
	});
}

…and somewhere on a page this:

1
	<input type="button" onclick="resetForm('formId');" />




How to access iframe in jQuery

Assuming you have

1
  <iframe id="iframeID" ...></iframe>

Iframe contains div with id=”someID”:

1
  <div id="someID">Hello world!</div>

Need get div’s text?

1
  $('#iframeID').contents().find('#someID').html();

just few words

1.5 months ago, 6 weeks or 42 days. I haven’t updated my simple blog since that time.

I haven’t a time to deal with my CakePHP projects, but got a pretty nice experience with other things.

Currently I work with Propel based custom framework with extensive usage of jQuery which I found very nice and going to use with CakePHP (when I have a time of course :) ).

Propel is very handy thing as well, it plays role of database communication layer, in other words Propel is ‘model’ component of a framework.

Well, I’m new to these things and sometimes spend a lot of time to figure simple things, but I’m sure when say “Propel rocks! jQuery rocks!” :)