Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: JS issue

  1. #1
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default JS issue

    Need some JS help i found this js contect form on this forum and i edited it abit well i added onloading but it shows the stuff from submit.php fast then it shows the loading stuff for ever and ever??

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <
    head>
    <
    meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <
    title>Untitled Document</title>
    <
    script type="text/javascript" language="javascript" src="js/prototype.js"></script>
    <
    script language="javascript" type="text/javascript">
    function 
    submitForm()
    {
        
    name document.getElementById("name").value;
        
    email document.getElementById("email").value;
        
    message document.getElementById("message").value
        new 
    Ajax.Request('submit.php',
        {
            
    parameters: {namenameemailemailmessagemessage},
            
    onLoading: function()
            {
                
    document.getElementById('box').innerHTML '<div align="center"><img src="images/loading.gif" alt="Loading" /><br />Sending message please hold!</div>';
            },
            
    onSuccess: function(transport)
            {
                
    document.getElementById('box').innerHTML transport.responseText;
            }
        });    
    }
    </
    script>
    </
    head>

    <
    body>
    <
    div id="box" align="center">
      <
    form id="form" action="javascript:submitForm();" method="post">
          
    Name:<br />
          <
    input type="text" name="name" id="name" />
          <
    br />
        
    Email:<br />
        <
    input type="text" name="email" id="email" />
        <
    br />
        
    Message:<br />
        <
    textarea name="message" id="message" cols="45" rows="5"></textarea>
        <
    br />
        <
    input type="submit" name="button" id="button" value="Send" />
      </
    form>
    </
    div>
    </
    body>
    </
    html

  2. #2

    Default

    I don't use prototype, but if you want a jQuery alternative which is another javascript framework. I made you the same thing you've got - except in jQuery.

    http://www.zenithsites.com/tutorials/jquery/contact/

    How mine differs from yours is that mine doesn't have inline javascript so no action="" etc, you also want to make it so if someone has javascript turnt off, it will just submit the form and process it and give them a result. Thirdly - you don't need id's for everything you can get them via CSS selectors in jQuery like mine shows.

    Anyhow, enjoy! download is http://www.zenithsites.com/tutorials...ct/Contact.zip setup contact.php how you wish, any problems just ask.

    Edit: The include of the script is at the bottom because that's a way of 'onload' if you want to put it at the top, use the function like this.
    Code:
    $(document).ready(function(){
      // Onload
    });
    Last edited by Iszak; 19-12-2008 at 11:14 AM.

  3. #3
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default

    Thnx for that but i sort of want to use prototype as i find it less blotted but i will have a look at it as i mite use jquery for one thing bigger.

    any one no whats wrong with it.

  4. #4
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by VistaBoy View Post
    Thnx for that but i sort of want to use prototype as i find it less blotted but i will have a look at it as i mite use jquery for one thing bigger.

    any one no whats wrong with it.
    Dude, he just coded that for you, he wasted his time and you're not going to bother using that?

  5. #5
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default

    Quote Originally Posted by Calon View Post
    Dude, he just coded that for you, he wasted his time and you're not going to bother using that?
    Well at the start of the topic i ask ofr help with the code i shown. also he may have used his time to make that but i will use it to learn jquery but i never used it before so ill have to learn it but he has given me a starting point.

  6. #6

    Default

    Calon, it's okay if he doesn't want to use what I made it's fine. I just find that jQuery is a lot better than Prototype because you use more features from it compared to Prototype - which you usually require Scriptaculous. I think you'll find jQuery better once you learn to use it and if you want me to explain my script to you, I'm happy to.

  7. #7
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Iszak View Post
    Calon, it's okay if he doesn't want to use what I made it's fine. I just find that jQuery is a lot better than Prototype because you use more features from it compared to Prototype - which you usually require Scriptaculous. I think you'll find jQuery better once you learn to use it and if you want me to explain my script to you, I'm happy to.
    Iszak does know his jQuery very well. You can't deny it

    I can't use either libraries, but i find jQuery easier now.

  8. #8
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jackboy View Post
    Iszak does know his jQuery very well. You can't deny it

    I can't use either libraries, but i find jQuery easier now.
    It's pretty easy, using libraries, there are even site's providing tutorials on them, I find prototype/scriptaculous a lot better, but that's just my opinion.

  9. #9
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    I find prototype/scriptaculous a lot better, but that's just my opinion.
    It all depends on what you need and what you already know. If you want effects and pre-built stuff, go for scriptaculous. If you want a library you can build on to then I'd go to jQuery.

  10. #10

    Default

    Simon, you're comparing Scriptaculous with jQuery when you should be comparing either jQuery and Prototype or jQuery UI and Scriptaculous. In either arguments, jQuery and jQuery UI does provide a set pre-built 'stuff', and also allows you to build on it. Some of these pre-built stuff in jQuery UI include the following.

    Core: Draggable, Droppable, Sortable, Selectable, Resizeable
    Widgets: Accordion, Datepicker, Dialog, Progressbar, Slider, Tabs
    Effects: Blind, Clip, Drop, Explode, Fold, Puff, Slide, Scale, Size, Pulsate, Bounce, Highlight, Shake, Transfer

    And again you have a large set of pre-build features in jQuery too so in no way are either of them not pre-built. As for building onto them, you can build plugins for jQuery, in fact this is how most of the effects are probably added.

    Example of adding a plugin, both have their purposes.
    Code:
    jQuery.newFunction = function()
    {
      // Code.
    }
    Or.
    Code:
    jQuery.fn.newMethod = function()
    {
      // Code.
    }
    Last edited by Iszak; 21-12-2008 at 04:28 AM.

Page 1 of 2 12 LastLast

Posting Permissions

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