By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,510 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,510 IT Pros & Developers. It's quick & easy.

prototype autocompleter 2 variables

P: n/a
Hi, I'm trying to have two input field ie:

who |mickey mouse| <- value is "mickey mouse"

when |12...|
|12-5-2005|


they work perfectly, but i'd like to have the variable i've previously
chosed in one of the input field sent along the new one i'm writing.
in this case, i'd like to send "12" with the variable $who setted lile
"mickey mouse"

in this way i could suggest related stuff.

couldn't find a solution, do you have any idea?

Thank you

--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 14 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Motion Musso aka: Sathia wrote:
Hi, I'm trying to have two input field ie:

who |mickey mouse| <- value is "mickey mouse"

when |12...|
|12-5-2005| ^^^^^^^^^^^^^^^^
they work perfectly, but i'd like to have the variable i've previously ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ chosed in one of the input field sent along the new one i'm writing. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ in this case, i'd like to send "12" with the variable $who setted lile ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "mickey mouse" ^^^^^^^^^^^^^^ in this way i could suggest related stuff.

couldn't find a solution, do you have any idea?


Parse error (after three passes). Please restate your request.
PointedEars
Mar 14 '06 #2

P: n/a
Thomas 'PointedEars' Lahn wrote:
Parse error (after three passes). Please restate your request.


yes, i know there are old fart at play between parser, nevermind, i don't
care about netscape 4 or this kind of comments
PointedEars


--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 14 '06 #3

P: n/a
Thomas 'PointedEars' Lahn wrote:
Parse error (after three passes). Please restate your request.

you can guess yourself i'm not english or american

btw if you can help i will do my best to re-post the thread at the best of
my poor english.

PointedEars


--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 14 '06 #4

P: n/a
motion musso aka: sathia wrote:
Thomas 'PointedEars' Lahn wrote:
Parse error (after three passes). Please restate your request.


yes, i know there are old fart at play between parser, nevermind, i don't
care about netscape 4 or this kind of comments


You missed the point.
PointedEars
Mar 14 '06 #5

P: n/a
motion musso aka: sathia wrote:
Thomas 'PointedEars' Lahn wrote:
Parse error (after three passes). Please restate your request.
^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ you can guess yourself i'm not english or american
I am not either.
btw if you can help i will do my best to re-post the thread at
the best of my poor english.


If you wish to be helped, please do so, as I asked already.
PointedEars
Mar 14 '06 #6

P: n/a
Thomas 'PointedEars' Lahn wrote:
motion musso aka: sathia wrote:
btw if you can help i will do my best to re-post the thread at
the best of my poor english.


If you wish to be helped, please do so, as I asked already.


To avoid a misunderstanding: Do not re-post! Ever.
Restate your request within _this_ thread instead.
PointedEars
Mar 14 '06 #7

P: n/a
Thomas 'PointedEars' Lahn wrote:

btw if you can help i will do my best to re-post the thread at
the best of my poor english.
If you wish to be helped, please do so, as I asked already.


ok. the point is:

i have a page with a form, in this form there are 2 "input text" field.
i want to give the user an autocompletion div on each of them.

obviously each autocompletion div refers to a different server side page.
ie:

who |venus| => who.php

when |2006-[...]| => when.php

let's suppose that the user has selected "venus" from the suggested list.

i'd like to let know the "when.php" page to look only records that are both
of "venus" and start with "2006-"

obviously this has to work in each direction, who => when || when => who

i can't explain myself any better than this.
i'm sorry for my poor english.

regards

PointedEars


Sathia

--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 14 '06 #8

P: n/a
motion musso aka: sathia wrote:

i can't explain myself any better than this.
i'm sorry for my poor english.


var answer = undefined;

:P

--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 14 '06 #9

P: n/a
motion musso aka: sathia wrote:
Thomas 'PointedEars' Lahn wrote:
btw if you can help i will do my best to re-post the thread at
the best of my poor english. If you wish to be helped, please do so, as I asked already.


ok. the point is:

i have a page with a form, in this form there are 2 "input text" field.
i want to give the user an autocompletion div on each of them.

obviously each autocompletion div refers to a different server side page.
ie:

who |venus| => who.php

when |2006-[...]| => when.php

let's suppose that the user has selected "venus" from the suggested list.

i'd like to let know the "when.php" page to look only records that are
both of "venus" and start with "2006-"

obviously this has to work in each direction, who => when || when => who


You better use only one server-side script. On change of either text input
control, or on submit of the form, use the value of each control as request
parameter. On submit:

<form action="whatever.php">
<input name="who">
<input name="when">
...
</form>

To facilitate this on change of either text input control, you will have to
make an XML HTTP request. Quickhack:

<form action="whatever.php" onchange="makeRequest(this);">
<script type="text/javascript">
/**
* @author
* (C) 2003, 2004 Thomas Lahn &lt;ty******@PointedEars.de&gt;
* Distributed under the GNU GPL v2.
* @partof
* http://pointedears.de/scripts/types.js
* @optional string s
* String to be determined a method type, i.e. "object"
* in IE, "function" otherwise. The type must have been
* retrieved with the `typeof' operator, thus this method
* is applicable to unknown properties while
* @link{#isMethod()} is not. Note that this method
* may also return <code>true</code> if the value of
* the <code>typeof</code> operand is <code>null</code>; to
* be sure that the operand is a method reference, you have
* to && (AND)-combine the <code>isMethodType(...)</code>
* expression with the method reference identifier.
* @return type boolean
* <code>true</code> if <code>s</code> is a method type,
* <code>false</code> otherwise.
* @see #isMethod()
*/
function isMethodType(s)
{
return (s == "function" || s == "object");
}

/**
* Tries hard to escape a string according to the query component
* specification in RFC3986.
*
* @author Copyright (c) 2006
* Thomas Lahn &lt;st*******@PointedEars.de&gt;
* Distributed under the GNU GPL v2.
* @partof
* http://pointedears.de/scripts/string.js
* @param s: string
* @return type string
* <code>s</code> escaped, or unescaped if escaping through
* <code>encodeURIComponent()</code> or <code>escape()</code>
* is not possible.
*/
function esc(s)
{
return (isMethodType(typeof encodeURIComponent)
? encodeURIComponent(s)
: (isMethodType(typeof escape)
? escape(s)
: s));
}

function makeRequest(f)
{
var
query = [],
m = (f.method && f.method.toUpperCase()) || "GET";

for (var i = 0, es = f.elements, len = es && es.length;
i < len;
i++)
{
var e = es[i];
if (e.type.toLowerCase() == "text")
{
if (i > 0) query.push("&");
query.push(esc(e.name) + "=" + esc(e.value));
}
}
query = query.join("");

var x = new XMLHttpRequest();
x.open(m, f.action + ((m == "GET") ? ("?" + query) : ""));

if (isMethodType(typeof x.setRequestHeader))
{
x.setRequestHeader("Content-Type",
"application/x-www-url-encoded");
}

x.onreadystatechange = function()
{
if (x.readyState == 4 && /^[02]/.test(x.status))
{
changeContentOfDivElement();
displayDivElement();
}
}

x.send((m != "GET") ? query : null);
}
</script>
<div>
<input name="who">
<input name="when">
</div>
...
</form>

The `change' event should bubble, therefore it could be handled by an
ancestor element, in this case the `form' element.

See also Google Suggest: <URL:http://www.google.com/webhp?complete=1>
i can't explain myself any better than this.
i'm sorry for my poor english.


It was much better now. (Just remember that the pronoun is spelled "I"
always, and that sentences usually start with a capital letter, as in
many other languages, including your native one.)
HTH

PointedEars
Mar 14 '06 #10

P: n/a
motion musso aka: sathia wrote:
motion musso aka: sathia wrote:
i can't explain myself any better than this.
i'm sorry for my poor english.


var answer = undefined;

:P


USENET is not a real-time communications medium. You should choose
which answer you like more: the quick, and maybe factually wrong;
or the correct one that usually takes more time. That said, nobody
here is obliged to solve your problems. People that are helping
you here in an attempt to solve your problem are merely doing you
a favor (or they refuse to do so). (Such favors have to be earned:
by showing a true desire to learn, by not acting like a complete idiot,
for example. And they are expected to be returned one way or the
other.)
PointedEars
Mar 14 '06 #11

P: n/a
Thomas 'PointedEars' Lahn wrote:
USENET is not a real-time communications medium. You should choose
which answer you like more: the quick, and maybe factually wrong;
or the correct one that usually takes more time. That said, nobody
here is obliged to solve your problems. People that are helping
you here in an attempt to solve your problem are merely doing you
a favor (or they refuse to do so). (Such favors have to be earned:
by showing a true desire to learn, by not acting like a complete idiot,
for example. And they are expected to be returned one way or the
other.)


Ok, I'm already studying your answer, I find it lovely at a first sight.
Look, I know exactly how usenet works and I know all the point you have
wrote above.
I'm really sorry if that hurted you, but it was meant to be ironic.

so, let me just have dinner here, and I'll be on that wonderful explanation
you gave.

I'm really sorry for these misunderstandings, thank you.

Sathia

--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 14 '06 #12

P: n/a
motion musso aka: sathia wrote:
I'm really sorry for these misunderstandings, thank you.


ACK, no offense meant or taken.
PointedEars
Mar 14 '06 #13

P: n/a
Thomas 'PointedEars' Lahn wrote:
motion musso aka: sathia wrote:
I'm really sorry for these misunderstandings, thank you.


ACK, no offense meant or taken.
PointedEars

Well, yesterday night I've been able to obtain what we discussed.
Anyway I didn't use the 'changhe' method because it would fail on some
situation.
I call the XML HTTP Request with a method of the prototype library.
Thank you for your ideas.

Byes

--
Vedo gli amici ancora sulla strada, loro non hanno fretta,
rubano ancora al sonno l'allegria all'alba un po' di notte:
e poi la luce, luce che trasforma il mondo in un giocattolo.
Faremo gli occhiali così, Faremo gli occhiali così!
Mar 15 '06 #14

P: n/a
Motion Musso aka: Sathia wrote:
Well, yesterday night I've been able to obtain what we discussed.
Anyway I didn't use the 'changhe' method because it would fail on
some situation.
As I said, it is a quickhack, completely untested. In what situations
exactly did it fail?
I call the XML HTTP Request with a method of the prototype library.


Which fails in even more situations.
PointedEars
Mar 15 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.