Alpha Video Training
Results 1 to 9 of 9

Thread: Passing contents of <form> input to Ajax callback

  1. #1
    Member
    Real Name
    Antony
    Join Date
    May 2004
    Posts
    67

    Default Passing contents of <form> input to Ajax callback

    Is it possible to pass the contents of:

    <input type="text" id="qty" name="qty">

    via A5.ajax.callback ?



    I want to type in a quantity then press the button that does my callback.

    Thanks

  2. #2
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,649

    Default Re: Passing contents of <form> input to Ajax callback

    Are you doing this on an a5w page? How are you doing the callbck?

  3. #3
    Member
    Real Name
    Antony
    Join Date
    May 2004
    Posts
    67

    Default Re: Passing contents of <form> input to Ajax callback

    <script>
    function doAjaxCallback() {
    A5.ajax.callback('AddToBasket.ajax.a5w','qty=1&item=<%a5?alltrim(str(part))%>');
    }
    </script>

    As you can see I have hardcoded qty=1, but I want to pass the contents of a textbox instead.

  4. #4
    "Certified" Alphaholic
    Real Name
    Gaby Hernandez
    Join Date
    Sep 2008
    Posts
    1,170

    Default Re: Passing contents of <form> input to Ajax callback

    Hi Anthony:
    See if the attached helps you.
    Attached Files Attached Files

  5. #5
    Member
    Real Name
    Antony
    Join Date
    May 2004
    Posts
    67

    Default Re: Passing contents of <form> input to Ajax callback

    Thanks, but I am avoiding using any Alpha grids - all my code is hand written html/a5w pages.

    Just to clarify how I am calling the above script on my .a5w page.


    <button onclick="doAjaxCallback();">Buy</button>

  6. #6
    "Certified" Alphaholic
    Real Name
    Gaby Hernandez
    Join Date
    Sep 2008
    Posts
    1,170

    Default Re: Passing contents of <form> input to Ajax callback

    All you need to do is copy the inline js in the row button to your button on the page: <button onclick="the inline ajaxcb js;">Buy</button>

  7. #7
    Member
    Real Name
    Antony
    Join Date
    May 2004
    Posts
    67

    Default Re: Passing contents of <form> input to Ajax callback

    Let me explain a little better

    I have a .a5w page (no grids) with the following code:

    Code:
    <input style="position:relative;top:0px;width:30px" size="4" maxlength="4" name="qty" id="qty" class="qty" value="1">
    <button onclick="doAjaxCallback();">Buy</button>
    
    <script>
    function doAjaxCallback() {
    A5.ajax.callback('addtobasket.ajax.a5w','qty=1&item=<%a5?alltrim(str(part))%>');
    }
    </script>
    This works fine but is only ever passing "1" as the qty because it is hard coded 'qty=1'

    What I want to do is pass the value the user may enter into the form control named 'qty' instead. These are not local xbasic variables, so not sure how to go about this.

  8. #8
    Member
    Real Name
    Antony
    Join Date
    May 2004
    Posts
    67

    Default Re: Passing contents of <form> input to Ajax callback

    No worries I figured it out

    Code:
    <script>
    function doAjaxCallback() {
    A5.ajax.callback('addtobasket.ajax.a5w','qty=' + document.getElementById('qty').value + '&item=<%a5?alltrim(str(part))%>');
    }
    </script>

  9. #9
    Volunteer Moderator drgarytraub's Avatar
    Real Name
    Dr. Gary Traub
    Join Date
    May 2000
    Location
    Boca Raton, FL
    Posts
    2,784

    Default Re: Passing contents of <form> input to Ajax callback

    I have what I think is a similar problem. Parent grid calls a child grid with action java script. I link the 2 grids on idnumber so that when I enter a new record in the child grid it will automatically insert idnumber in to the child's new record. This works as long as the child grid has at least one record. What am I missing here?
    Gary S. Traub, Ph.D.


Similar Threads

  1. AJAX Callback to update Enter Record Form?
    By njw1314 in forum Application Server Version 10 - Web/Browser Applications
    Replies: 6
    Last Post: 09-05-2011, 12:50 AM
  2. Ajax Callback
    By lvasic in forum Application Server Version 10 - Web/Browser Applications
    Replies: 2
    Last Post: 08-18-2011, 09:35 AM
  3. AJAX callback from tabbedUI
    By Steve Wood in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 09-29-2010, 11:47 AM
  4. Ajax callback - where is the data
    By leec2000 in forum Application Server Version 10 - Web/Browser Applications
    Replies: 5
    Last Post: 06-03-2010, 10:41 PM
  5. AJAX Callback question
    By Mike Reed in forum Application Server Version 9 - Web/Browser Applications
    Replies: 3
    Last Post: 04-27-2009, 11:14 AM

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
  •