Rails AJAX help

Discussion in 'Ruby' started by danielks@gmail.com, Sep 4, 2006.

  1. Guest

    I have an input, and I want to, when the user types a number on that
    input and exits it (the onBlur event), to search a table on that number
    and return a value to that input.

    Thanks in advance.
     
    , Sep 4, 2006
    #1
    1. Advertising

  2. Guest

    But my problem is not how to find the value, but the AJAX
    implementation in the onBlur event and how to return the value found
    back to the input.

    Paul Lutus escreveu:

    > wrote:
    >
    > > I have an input, and I want to, when the user types a number on that
    > > input and exits it (the onBlur event), to search a table on that number
    > > and return a value to that input.

    >
    > Had you considered the idea of using the user's entered number as an index
    > into an array?
    >
    > --
    > Paul Lutus
    > http://www.arachnoid.com
     
    , Sep 4, 2006
    #2
    1. Advertising

  3. James Britt Guest

    Paul Lutus wrote:
    > wrote:
    >
    >
    >>But my problem is not how to find the value, but the AJAX
    >>implementation in the onBlur event and how to return the value found
    >>back to the input.

    >
    >
    > It would be very helpful if you were to post your code and ask specific
    > questions about problems you are having with your code.



    onblur() needs to invoke a javascript function. That function should:
    do an HttpXmlRequest call to the server, see if it gets a usable
    response, and set the input field's 'value' property to the returned
    value if good.

    Give your input elements unique id attributes. Makes it easier to
    locate them. Then (assuming the use of prototype.js) you can do
    $(theInputID).value = theReturnedGoodValue in the callback method.

    Hand-coding the javascript for this is pretty straightforward, but if
    you get stuck, ask for help on a JavaScript list. It's off-topic for
    the main Ruby list.

    If you are looking to use Rails helper methods or RJS, you would do
    better to ask for help on the Rails list.



    --
    James Britt

    "Programs must be written for people to read, and only incidentally
    for machines to execute."
    - H. Abelson and G. Sussman
    (in "The Structure and Interpretation of Computer Programs)
     
    James Britt, Sep 4, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. minnie
    Replies:
    1
    Views:
    756
    Andrew Thompson
    Dec 13, 2006
  2. JDeats
    Replies:
    1
    Views:
    1,006
    bruce barker
    Oct 5, 2007
  3. J. D.
    Replies:
    9
    Views:
    190
    Jamis Buck
    Nov 4, 2004
  4. Replies:
    6
    Views:
    201
    Michael Campbell
    Mar 17, 2005
  5. Curt Hibbs
    Replies:
    4
    Views:
    116
    Stephen Kellett
    Jun 11, 2005
Loading...

Share This Page