[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rails AJAX help

danielks@gmail.com

9/4/2006 6:45:00 PM

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.

5 Answers

Paul Lutus

9/4/2006 7:55:00 PM

0

danielks@gmail.com 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.ara...

danielks@gmail.com

9/4/2006 8:02:00 PM

0

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:

> danielks@gmail.com 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.ara...

Paul Lutus

9/4/2006 8:21:00 PM

0

danielks@gmail.com 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.

--
Paul Lutus
http://www.ara...

James Britt

9/4/2006 8:43:00 PM

0

Paul Lutus wrote:
> danielks@gmail.com 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)

Dave Peterson

11/12/2008 6:47:00 PM

0

In your case, the value in that cell is really the string "10 Nov 08".

But if you had a real date in that cell and it was formatted to show "10 Nov
08", then the value would be the real date (11/10/2008 for me with my
settings)--not the string that you see.

So there's a difference between the .text property (what you see) and the .value
property (what you may see in the formula bar.

I can format a date (11/10/2008) to show November 10, 2008 in the cell. But the
..value is 11/10/2008.

The .value isn't a legal name (since it contains the slashes (with my USA
settings)).

The .Text is ok.

If I formatted the date to show:
Monday November 10, 2008
(with all those extra spaces)

Then that wouldn't be a valid worksheet name, either--since it's longer than 31
characters.



"Patrick C. Simonds" wrote:
>
> And example of a value that appears in cell AB1 would be 10 Nov 08. That
> is achieved by the the formula located in cell AB1 "=TEXT(B4,"dd mmm yy")".
>
> What did you mean by "If you've already formatted the cells nice (and
> legal)"? How should the cell be formatted?
>
> "Dave Peterson" <petersod@verizonXSPAM.net> wrote in message
> news:491AD502.DA8EBB43@verizonXSPAM.net...
> > Another problem could be that the value in AB1 is a date. With my USA
> > settings,
> > that .value would be equal to something like:
> >
> > 11/12/2008
> >
> > And worksheet names can not have slashes in them.
> >
> > If you've already formatted the cells nice (and legal), you could use:
> >
> > Sh.Name = Sh.Range(sStr).Text 'what appears in the cell, not the .value
> >
> > or you could format it the way you like:
> >
> > Sh.Name = format(Sh.Range(sStr).Value, "dd mmm yyyy") 'I like 4 digit
> > years!
> >
> >
> > "Patrick C. Simonds" wrote:
> >>
> >> Can someone tell me why this code fails? It triggers the MsgBox. The
> >> contents of cell AB1 is =TEXT(B4,"dd mmm yy"). Also what format should
> >> be
> >> given to cell AB1?
> >>
> >> Sub Rename_Worksheets()
> >> '
> >> ' Macro1 Macro
> >> ' Macro recorded 12/19/2005 by Cathy Baker
> >> '
> >>
> >> '
> >>
> >> 'This code runs to rename the worksheets
> >>
> >> Dim wks As String
> >> Dim Sh As Worksheet
> >>
> >> wks = ActiveSheet.Name
> >>
> >> Const sStr As String = "AB1"
> >>
> >> On Error GoTo ErrHandler
> >> For Each Sh In ThisWorkbook.Worksheets
> >> Sh.Name = Sh.Range(sStr).Value
> >> Next Sh
> >>
> >> Worksheets(wks).Activate
> >>
> >> Exit Sub
> >> ErrHandler:
> >> MsgBox "Cell" & sStr & "on sheet" & sh.Name & "is not valid sheet name"
> >> Resume Next
> >>
> >> End Sub
> >
> > --
> >
> > Dave Peterson

--

Dave Peterson