Hey Guys,
I tried to simplify this alot... and wrote this code and my understanding of
what each thing does... but I have yet to get it to work :o) but not giving
up! can you guys get this to work or see something obvious that I am doing
wrong.. I am using prototype 1.6.0.2 and safari or firefox
PHP code : proto_test_script.php
--------------------------------------------------------------------------------------
<?="Good Day, ".$_GET[''name'']?>
HTML Page with prototype scripting : proto_test.php
--------------------------------------------------------------------------------------
<!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>Testing Prototype</title>
<script type="text/javascript"
src="../prototype.js"></script>
<script>
function makeGreeting()
{
new Ajax.Request(
''proto_test_script.php'', // This is the Script that is
called
{
// The Method of passing the variable
method: ''GET'',
// The Variable(Parameters) that is passed to proto_test_script
parameters: ''name='' + $F(''name''),
// Assign the response of proto_test_script.php to transport.responseText
onSuccess:function(transport)
{
// Change the field greeting
$F(''greeting'') = transport.responseText;
}
}
);
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post"
action="">
What is your name :
<input type="text" name="name" id="name"
onKeyUp="makeGreeting();"/>
<br />
<input name="greeting" type="text"
id="greeting" size="50" />
</form>
</body>
</html>
--
Joe Harman
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
it''s been a while, but I''m not sure if $F is reliable when
used to update a
field value - IE vs FF vs Saf thing - i''d use
$(''greeting'').value whatever.
but -- have you tried ajax.updater?
and passed it ''greeting'' as the element parameter?
something to the effect of
new Ajax.Updater(''greeting'',
''proto_test_script.php'',
{
method: ''GET'',
parameters: ''name='' +
$F(''name'')
})
On Tue, Mar 25, 2008 at 12:10 PM, Joe Harman
<cjharman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hey Guys,
> I tried to simplify this alot... and wrote this code and my understanding
> of what each thing does... but I have yet to get it to work :o) but not
> giving up! can you guys get this to work or see something obvious that I am
> doing wrong.. I am using prototype 1.6.0.2 and safari or firefox
>
> PHP code : proto_test_script.php
>
>
--------------------------------------------------------------------------------------
>
> <?="Good Day, ".$_GET[''name'']?>
>
>
>
> HTML Page with prototype scripting : proto_test.php
>
>
--------------------------------------------------------------------------------------
>
> <!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>Testing Prototype</title>
> <script type="text/javascript"
src="../prototype.js"></script>
> <script>
> function makeGreeting()
> {
> new Ajax.Request(
> ''proto_test_script.php'', // This is the Script that is
called
> {
> // The Method of passing the variable
> method: ''GET'',
> // The Variable(Parameters) that is passed to proto_test_script
> parameters: ''name='' + $F(''name''),
> // Assign the response of proto_test_script.php to transport.responseText
> onSuccess:function(transport)
> {
> // Change the field greeting
> $F(''greeting'') = transport.responseText;
> }
> }
> );
> }
> </script>
> </head>
> <body>
> <form id="form1" name="form1"
method="post" action="">
> What is your name :
> <input type="text" name="name"
id="name" onKeyUp="makeGreeting();"/>
> <br />
> <input name="greeting" type="text"
id="greeting" size="50" />
> </form>
> </body>
> </html>
>
> --
> Joe Harman
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
On Tue, Mar 25, 2008 at 11:10 AM, Joe Harman <cjharman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> $F(''greeting'') = transport.responseText;$F() is a reader only, it cannot be used as a setter. After all, it''s just a function call and you cannot assign a value to a function call in JavaScript (to my knowledge). Like Brian suggested, you want to assign the value using traditional means. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Brain & Justin... I just switched it around and I still could not get it
to work... this is what I did
function makeGreeting()
{
new Ajax.Updater(
''greeting'',
''proto_test_script.php'', // This is the Script that is
called
{
// The Method of passing the variable
method: ''GET'',
// The Variable(Parameters) that is passed to proto_test_script
parameters: ''name='' + $F(''name'')
}
);
}
On Tue, Mar 25, 2008 at 11:42 AM, Justin Perkins
<justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
>
> On Tue, Mar 25, 2008 at 11:10 AM, Joe Harman
<cjharman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > $F(''greeting'') = transport.responseText;
>
> $F() is a reader only, it cannot be used as a setter. After all,
it''s
> just a function call and you cannot assign a value to a function call
> in JavaScript (to my knowledge).
>
> Like Brian suggested, you want to assign the value using traditional
> means.
>
> -justin
>
> >
>
--
Joe Harman
SCP Performance Parts Warehouse
3475 High Ridge Blvd
High Ridge, MO 63049
Office : (636) 677-1320
Cell : (269) 277-0717
http://www.scpracingparts.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
There''s a (not yet documented) #setValue method (since 1.6) - kangax On Mar 25, 12:46 pm, "Joe Harman" <cjhar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey Brain & Justin... I just switched it around and I still could not get it > to work... this is what I did > function makeGreeting() > { > new Ajax.Updater( > ''greeting'', > ''proto_test_script.php'', // This is the Script that is called > { > // The Method of passing the variable > method: ''GET'', > // The Variable(Parameters) that is passed to proto_test_script > parameters: ''name='' + $F(''name'') > > } > ); > } > > On Tue, Mar 25, 2008 at 11:42 AM, Justin Perkins <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > On Tue, Mar 25, 2008 at 11:10 AM, Joe Harman <cjhar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > $F(''greeting'') = transport.responseText; > > > $F() is a reader only, it cannot be used as a setter. After all, it''s > > just a function call and you cannot assign a value to a function call > > in JavaScript (to my knowledge). > > > Like Brian suggested, you want to assign the value using traditional > > means. > > > -justin > > -- > Joe Harman > > SCP Performance Parts Warehouse > 3475 High Ridge Blvd > High Ridge, MO 63049 > Office : (636) 677-1320 > Cell : (269) 277-0717 > > http://www.scpracingparts.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You cannot use an Ajax.Updater to update an input control. All the
updater does is basically call
$(''your-id'').update(''your Ajax
Response'') which will never work on an form control.
Switch back to using an Ajax.Request and an onSuccess handler like you
were doing before if you really want to update a form control.
-justin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
On Tue, Mar 25, 2008 at 12:04 PM, kangax <kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > There''s a (not yet documented) #setValue method (since 1.6)True, but isn''t it Form.Element.setValue(''id, ''value'') ? $(''id'').value = ''value'' is still pretty easy :) -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Guys, I was able to solve it by using
Form.Element.setValue("greeting", transport.responseText);
I actually discovered this at
http://jehiah.cz/archive/form-element-setvaluewhich had an add on
called
prototypeUtils.js <http://jehiah.com/download/prototypeUtils.js>
Thanks alot guys!
Joe
On Tue, Mar 25, 2008 at 12:18 PM, Justin Perkins
<justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
>
> On Tue, Mar 25, 2008 at 12:04 PM, kangax
<kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> >
> > There''s a (not yet documented) #setValue method (since 1.6)
>
> True, but isn''t it Form.Element.setValue(''id,
''value'') ?
>
> $(''id'').value = ''value'' is still pretty
easy :)
>
> -justin
>
> >
>
--
Joe Harman
SCP Performance Parts Warehouse
3475 High Ridge Blvd
High Ridge, MO 63049
Office : (636) 677-1320
Cell : (269) 277-0717
http://www.scpracingparts.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Yep, Form.Element#setValue or a shortcut: Field#setValue $(element).setValue(value) is easy as well, don''t you think? : ) - kangax On Mar 25, 1:18 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Mar 25, 2008 at 12:04 PM, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > There''s a (not yet documented) #setValue method (since 1.6) > > True, but isn''t it Form.Element.setValue(''id, ''value'') ? > > $(''id'').value = ''value'' is still pretty easy :) > > -justin--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---