I have one form on my page, and it has an id, and is contained in a
div with an id, however I tried calling the form with it's id then
using "reset()" and it stopped working.

All I'm asking for is a way to reset my form, rather than using a
generic array with an arbitrary index.

I need better code than $("form")[1].reset();

Here is the html code:
<code>                  <div id="editingpost">
                        <form id="editingform">

                                blog title: <br />

                                <input type="text" size="60" id="blogtitle">

                                <br />

                                Author: <input type="text" size="30" 
id="blogauthor">

                                <textarea cols="50" rows="15" 
id="blogbody"></textarea><br />

                        </form>
                        <button onClick="addBlog();">Add</button>
                        </div></code>
Here is the javascript code:
<code>function addBlog()
{
        //the executePage function should call .post then return the text of
the page.
        $.post("newpost.php",
                //parameters.
                {
                blogtitle: $("#blogtitle").val(),
                blogauthor: $("#blogauthor").val(),
                blogbody: $("#blogbody").val()
                },
                //after executing page, do this function, "reply" is the text
returned by the page.
                function(reply)
                {
                        if(reply=="Success!")
                        {
                                $("form")[1].reset();   //is their a better way 
to do this?

                                $("#editingpost").append("<br /><center><font 
color='green'>Post
added!</font></center>");

                                $.get("postlist.php", function(psts){
                                        $("#postlist").html(psts); //update 
postlist.
                                });
                        }
                        else
                        {
                                $("#editingpost").append("<br /><font 
color='red'>Posting Failed!</
font>");
                        }
                }
        );
}               </code>

(if i used the code tags out of context my apologies, I've never used
an email group before.)

Thanks in advanced,

-Jason

Reply via email to