Results 1 to 10 of 18

Thread: Ajax and Forms

Threaded View

charlesh Ajax and Forms 09-27-2008, 04:28 PM
jmarcv I develop in Firefox with the... 09-27-2008, 07:01 PM
charlesh Jmarcv, Thanks for the... 09-27-2008, 09:16 PM
jmarcv Charles H :rolleyes: The... 09-27-2008, 10:29 PM
jmarcv Actually, now that you... 09-27-2008, 10:38 PM
jmarcv PPS - Download details:... 09-27-2008, 10:49 PM
charlesh John-Marc, Thanks for the... 09-28-2008, 11:45 AM
charlesh I'm still a hack web... 09-28-2008, 12:01 PM
jmarcv Yes you are, and thats my... 09-28-2008, 12:14 PM
charlesh Thanks for the compliment,... 09-28-2008, 01:50 PM
charlesh This works, but a bit... 09-28-2008, 02:35 PM
jmarcv LOL! That and AJAXIFY it. ... 09-28-2008, 02:56 PM
charlesh Jmarc, I think I did what... 09-28-2008, 09:06 PM
jmarcv Backhanded indeed. Not a... 09-29-2008, 09:57 PM
charlesh Now you're making me feel... 09-29-2008, 10:30 PM
jmarcv Be guilty! Be VERY guilty! ... 09-30-2008, 09:49 AM
jmarcv Yo, CH! Curious to see... 10-12-2008, 12:27 PM
charlesh Shelved it for now - had been... 10-13-2008, 10:33 AM
Previous Post Previous Post   Next Post Next Post
  1. #1
    charlesh's Avatar
    charlesh is offline Master Glow Jedi
    Join Date
    Aug 2006
    Location
    Atlanta, GA - better than you imagined it would be.
    Posts
    189

    Default Ajax and Forms

    All,

    One thing I totally dislike is doing form validation, so I thought I would spice it up a bit by doing some Ajax and instant feedback type of form. Specifically, when you enter a username, I have a function that will check to see if that username exists in the database via a XMLHTTP request in the background. Try typing in "admin" to see a return on an existing username. Really, Ajax is not so difficult. What is difficult is troubleshooting Javascript!

    The other neat thing is that when you choose a state, the database is queried and only the universities for that state will appear in the next select box down. So, choose a state first and then the universities will appear for that state. I'm thinking of writing a tutorial on how I did this, if any one is interested - let me know.

    For those of you who wouldn't mind giving me some constructive feedback about the form in progress, I would sincerely appreciate it, especially since it is my first attempt at Ajax.

    What I'm having trouble with figuring out is how to (in Javascript) only return true with the order form when all the required fields are either correct and filled out. There must be some way to have all of those functions that I have for checking the database and returning the universities list feed into an array I can check on a submit. Any ideas? Right now the required fields validate individually, but not as a complete form.

    The simple way with one function is a bunch of chained if statements (see below)...

    Code:
      else if(document.contact.state.value=='abc') {
             document.getElementById('state_help').innerHTML = '<img src="http://glowhost.com/forums/images/info.jpg" alt="" width="25" height="24" /><br/>&nbsp;&nbsp;Please Choose a state.';
                    return false;
            }
                   
            else {
                    return true;
            }
    and when all the conditions are met, then the form returns true and the post executes to the php script. Problem is, I have several different "separate" functions for the ajax-specific field, so how do I evaluate everything together for a post?

    Here's the link:
    Campus Mic

    Any help is warmly appreciated,
    Last edited by charlesh; 09-27-2008 at 04:30 PM.

LinkBacks (?)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14