Hello!
Yesterday I found the prototype script and a tutorial about it in
German.
There was a index.html (see below), the prototype.js, the ajax.js
(also below) and a greeting.php (below). In this example there is a
input field. If you click in it, the text in the greeting div changes
into the inserted text.
But now I don''t want to click into a input field. I want to click into
a picture, which should change automatically into another. So I tried
to change the input field into a div field:
Instead of <input id="greeting-name" type="text"> I
tried to write
<div id="greeting-name"><img src=''#''
width=100px height=100px></div>.
But this doesn''t work. What can I do that this script works?
p.s. sorry for my bad englisch (;
index.php
-------------
<head>
<script type="text/javascript"
src="prototype.js"></script>
<script type="text/javascript"
src="ajax.js"></script>
</head>
<body>
<input id="greeting-name" type="text">
<div id="greeting"></div>
ajax.js
--------
Event.observe(window, ''load'', init, false);
function init(){
Event.observe(''greeting-name'', ''click'',
greet, false);
}
function greet(){
var url = ''greeting.php'';
var pars =
''greeting-name=''+escape($F(''greeting-name''));
var target = ''greeting'';
var myAjax = new Ajax.Updater(target, url, {method:
''get'',
parameters: pars});
}
greeting.php
-----------------
<?php
$the_name = htmlspecialchars($_GET[''greeting-name'']);
echo "<p>$the_name!</p>";
?>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Try this:
function greet(){
alert(''working'');
var url = ''greeting.php'';
var pars =
''greeting-name=''+escape($F(''greeting-name''));
var target = ''greeting'';
var myAjax = new Ajax.Updater(target, url, {method:
''get'',
parameters: pars});
}
See if greet is being executed.
On Jul 17, 6:04 am, Thomas <thomas-spa...-S0/GAf8tV78@public.gmane.org>
wrote:> Hello!
> Yesterday I found the prototype script and a tutorial about it in
> German.
>
> There was a index.html (see below), the prototype.js, the ajax.js
> (also below) and a greeting.php (below). In this example there is a
> input field. If you click in it, the text in the greeting div changes
> into the inserted text.
> But now I don''t want to click into a input field. I want to click
into
> a picture, which should change automatically into another. So I tried
> to change the input field into a div field:
> Instead of <input id="greeting-name"
type="text"> I tried to write
> <div id="greeting-name"><img src=''#''
width=100px height=100px></div>.
> But this doesn''t work. What can I do that this script works?
>
> p.s. sorry for my bad englisch (;
>
> index.php
> -------------
> <head>
> <script type="text/javascript"
src="prototype.js"></script>
> <script type="text/javascript"
src="ajax.js"></script>
> </head>
> <body>
> <input id="greeting-name" type="text">
> <div id="greeting"></div>
>
> ajax.js
> --------
> Event.observe(window, ''load'', init, false);
> function init(){
> Event.observe(''greeting-name'',
''click'', greet, false);
>
> }
>
> function greet(){
> var url = ''greeting.php'';
> var pars =
''greeting-name=''+escape($F(''greeting-name''));
> var target = ''greeting'';
> var myAjax = new Ajax.Updater(target, url, {method:
''get'',
> parameters: pars});
>
> }
>
> greeting.php
> -----------------
> <?php
> $the_name =
htmlspecialchars($_GET[''greeting-name'']);
> echo "<p>$the_name!</p>";
> ?>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
If I put the alert at the beginning of the function grett, it shows
the alert. After the line "var myAjax = new Ajax.Updater(target, url,
{method: ''get'',> parameters: pars});" it
doesn''t work anymore.
You can see the probleme here: http://fcup.cwsurf.de/ajax/neu/
On 17 Jul., 15:26, Diodeus
<diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Try this:
>
> function greet(){
> alert(''working'');
> var url = ''greeting.php'';
> var pars =
''greeting-name=''+escape($F(''greeting-name''));
> var target = ''greeting'';
> var myAjax = new Ajax.Updater(target, url, {method:
''get'',
> parameters: pars});
>
> }
>
> See if greet is being executed.
>
> On Jul 17, 6:04 am, Thomas
<thomas-spa...-S0/GAf8tV78@public.gmane.org> wrote:
>
>
>
> > Hello!
> > Yesterday I found the prototype script and a tutorial about it in
> > German.
>
> > There was a index.html (see below), the prototype.js, the ajax.js
> > (also below) and a greeting.php (below). In this example there is a
> > input field. If you click in it, the text in the greeting div changes
> > into the inserted text.
> > But now I don''t want to click into a input field. I want to
click into
> > a picture, which should change automatically into another. So I tried
> > to change the input field into a div field:
> > Instead of <input id="greeting-name"
type="text"> I tried to write
> > <div id="greeting-name"><img
src=''#'' width=100px height=100px></div>.
> > But this doesn''t work. What can I do that this script works?
>
> > p.s. sorry for my bad englisch (;
>
> > index.php
> > -------------
> > <head>
> > <script type="text/javascript"
src="prototype.js"></script>
> > <script type="text/javascript"
src="ajax.js"></script>
> > </head>
> > <body>
> > <input id="greeting-name"
type="text">
> > <div id="greeting"></div>
>
> > ajax.js
> > --------
> > Event.observe(window, ''load'', init, false);
> > function init(){
> > Event.observe(''greeting-name'',
''click'', greet, false);
>
> > }
>
> > function greet(){
> > var url = ''greeting.php'';
> > var pars =
''greeting-name=''+escape($F(''greeting-name''));
> > var target = ''greeting'';
> > var myAjax = new Ajax.Updater(target, url, {method:
''get'',
> > parameters: pars});
>
> > }
>
> > greeting.php
> > -----------------
> > <?php
> > $the_name =
htmlspecialchars($_GET[''greeting-name'']);
> > echo "<p>$the_name!</p>";
> > ?>- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Is there a solution for my problem? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Looking at your script:
var pars =
''greeting-name=''+escape($F(''greeting-name''));
I don''t see this form field on your page. This is where it fails on my
test.
On Jul 18, 5:03 am, Thomas <thomas-spa...-S0/GAf8tV78@public.gmane.org>
wrote:> Is there a solution for my problem?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
var pars =
''greeting-name=''+escape($F(''greeting-name''));
Your page is missing the form field called "greeting-name''.
On Jul 18, 5:03 am, Thomas <thomas-spa...-S0/GAf8tV78@public.gmane.org>
wrote:> Is there a solution for my problem?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---