Results 1 to 2 of 2

Thread: AJAX advice anyone?

  1. #1
    Join Date
    Jul 2005
    Location
    UK
    Posts
    159
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default AJAX advice anyone?

    I've made a simple mailing list form nested in a div layer floating in the corner of the screen. its basically just a text field and submit button. is it possible to hide the div layer that the form is in, when the user clicks submit?

    here is the code for the form:
    Code:
    <!-- newsletter subscribe below here -->
    
    <script language="Javascript" type="text/javascript">
    var fieldstocheck = new Array();
    fieldnames = new Array();
    function checkform() {
    for (i=0;i<fieldstocheck.length;i++) {
    if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
    alert("Please enter your "+fieldnames[i]);
    eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
    return false;
    }
    }
    return true;
    }
    function addFieldToCheck(value,name) {
    fieldstocheck[fieldstocheck.length] = value;
    fieldnames[fieldnames.length] = name;
    }
    </script>
    
    <form method="post" action="http://www.mydomain.com/lists/?p=subscribe&id=1" name="subscribeform">
    Email:<input type="text" name="email" value = ""><br>
    <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email Address");</script>
    Name: <input type="text" name="attribute2" value = "">
    <script language="Javascript" type="text/javascript">addFieldToCheck("attribute2","Name");</script>
    <input type="hidden" name="list[1]" value="signup" />
    <input type="submit" name="subscribe" value="Subscribe" onClick="return checkform();">
    </form>
    
    <!-- newsletter subscribe ends here -->

  2. #2
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    If you know JavaScript, you should try this AJAX tutorial. I did it myself yesterday, and it's not that hard. By the time you finish the tutorial, you should have an idea of what to do. In fact, it covers the submission of forms, which is what you need. (If you know JS, it should only take an hour or less to get through. If your rough on JS, it might take longer.)
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

Bookmarks

Posting Permissions

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