Thanks again Blair, the [0] was the missing piece of my puzzle - I'd
never have picked it up.
Cheers,
Bruce
At 12:12 p.m. 20/12/2006, you wrote:
$("#sQuestion").resetInput(). Most plugins create new methods that
you can run on a jQuery selection.
I haven't actually had to reset an entire form before, but I would
expect that you would have to do $("#nLinkForm") [0].reset().
i.e.
$("#nLinkForm") // select the form
[0] // access the DOM element itself
.reset() // run the reset method on the element
Blair
On 12/19/06, Bruce MacKay
<<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> wrote:
Thanks Blair, this was helpful.
My major fault, it seems, was the .val, not .html issue. The
elements were inserted correctly.
I still cannot get $("#nLinkForm").reset(); to work, but by looping
through the form elements and setting their value to an empty string
or value to false:
for (var i=0;i<6;i++){
$("#fback"+i).val('');
$("#theans"+i).val('');
$("#bCorrect"+i).attr({checked:false});
}
does clear the form for me.
I'm sorry, but my level of understanding is quite low - what is the
syntax for using resetInput for, say, a text element (#sQuestion).
Cheers,
Bruce
At 11:23 p.m. 18/12/2006, you wrote:
jQ shouldn't have any problems finding the added elements. Some
things to look at:
First, use $("#sQuestion").val('abc') to change form input values, not html.
Have you tried looking at the DOM with FireBug to make sure the
elements are being inserted correctly?
In terms of what you're actually trying to do, I've used something
like this when I want to reset only part of a form:
jQuery.fn.resetInput() {
return this.each(function() { this.value=this.defaultValue; });
};
Blair
On 12/18/06, Bruce MacKay
<<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> wrote:
Sorry, a typo on my part - I am using #nLinkForm in the code
Bruce
At 07:58 p.m. 18/12/2006, you wrote:
$("nLinkForm") is looking for nLinkForm tags. You need to use css
syntax: $("#nLinkForm") for id, $(".nLinkForm") for class.
Blair
On 12/18/06, Bruce MacKay
<<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> wrote:
Hello folks,
Please excuse this longish post but I'm seriously confused.
I'm building a quiz editor. I have form (#nLinkForm) which is
loaded with the page and a submit function bound to it.
Once the user has selected the type of quiz, an appropriate set of
input elements (text, textarea, checkbox) is loaded into a div
(#aqs) within "nLinkForm" via an AJAX call. The questions/answers
entered into these elements are correctly send to the server when
the form is submitted.
My problem occurs next - I want to reset the form to clear all the
contents of the input elements in readiness for another set of
question/answers to be entered.
I have an image tag set up with the following code...
$("img.togAQs").click(function(){$("nLinkForm").reset();$("#aqs").slideDown("slow");});
which I had hoped would clear the contents of the text/textarea
etc elements of the form - it doesn't and hence this call for
help. What am I doing wrong? A workaround is to load a blank
"template" via another ajax call, but I was hoping to "clear the
decks" client-side.
I know the function as a whole is being fired as evidenced by the
contents of the "aqs" div becoming visible/sliding down.
After reading the archives, I also tried
$("nLinkForm")[0].reset(); to no benefit. Now, after trying
$("#sQuestion").html('abc'); as a check to change the contents of
one of the text input elements, I'm now thinking that jquery
cannot "see" the form elements within #aqs.
Is this the correct interpretation of what's happening/not
happening? If so, how do I ensure that jquery does recognise
elements introduced into a page via an AJAX call?
Thanks,
Bruce
_______________________________________________
jQuery mailing list
<mailto:[email protected]>[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
<mailto:[email protected]>[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
<mailto:[email protected]>[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
<mailto:[email protected]>[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
<mailto:[email protected]>[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/