Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Amby 30 posts 50 karma points
    Jun 30, 2011 @ 12:45
    Amby
    0

    Saving user input

    Hi,

    I am new to Umbraco. I have a pop up (using jquery dialog) to enter name and email id from user. The values are store in name.val() and email.val().How to save name and email id entered from the user to the database ?

    Regards,

    Ambika

     

     

     

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 30, 2011 @ 13:55
    Tom Fulton
    0

    Hi,

    There are many different ways you could achieve this.  One would be to create a /base extension, similar to a web service, and pass in the user's name/email through the URL  (like /base/Users/SaveUserInfo/Tom/[email protected]) - or you could POST the data to avoid having it in the URL.  In your base extension you could handle saving it to the database.

    Here is a blog post explaining how to create the base (RestExtension) in 4.7, it's very easy:  http://www.nibble.be/?p=95

    -Tom

  • Amby 30 posts 50 karma points
    Jun 30, 2011 @ 16:17
    Amby
    0

    Many Thanks Tom. I have the data in the script tag. Will the RestExtension still hold good?

    <script>

    $(function() {
    $( "#dialog" ).dialog({
       autoOpen: false,
       show: "blind",
       modal:true,
       hide: "slide",
       buttons: {
        "Create an account": function() {
         var bValid = true;
         allFields.removeClass( "ui-state-error" );

         bValid = bValid && checkLength( name, "username", 3, 16 );
         bValid = bValid && checkLength( email, "email", 6, 80 );
        

             
         if ( bValid ) {

    //Here i need to send the name.val() and email.val() to be stored in the table
             }
        },
        Cancel: function() {
         $( this ).dialog( "close" );
        }
       },
      });
    </script>

    Din't know the ways of passing the values in the dialog to the backend.

    - Amby

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 30, 2011 @ 16:24
    Tom Fulton
    0

    Hi Amby,

    What you'll want to do there is make an AJAX call to the RestExtension you create.  Look into jQuery.ajax to do this.  The URL would be something like "/base/Users/SaveUserInfo/" + name.val() + "/" + email.val()

    You'll need to create a RestExtension with two parameters (name/email) to handle the request and write the code to add to the database.

    Hope this helps,
    Tom

  • Amby 30 posts 50 karma points
    Jul 01, 2011 @ 13:14
    Amby
    0

    It worked.. Thanks Tom for the advice and the link.

    -Amby

  • Amby 30 posts 50 karma points
    Jul 11, 2011 @ 14:38
    Amby
    0

    Alternative way is to have a hidden field and use ajax submit() to post the page.

Please Sign in or register to post replies

Write your reply to:

Draft