473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

prototype autocompleter 2 variables

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
14 2819
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Elf M. Sternberg | last post by:
One of the complaints about prototype.js (google for it if you're not familiar with it) is that it's poorly documented. I have this inkling that the key to understanding prototype.js is in the...
13
by: Roy Hills | last post by:
I've seen two different function prototype formats used for ANSI C, and I'm unsure as to which is the correct or preferred one. 1st Format (this is what I use) type function(type, type, type);...
4
by: jemptymethod | last post by:
http://htmatters.net/htm/1/2006/01/EIBTI-for-Javascript-explicit-is-better-than-implicit.cfm
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
2
by: vlsidesign | last post by:
Here is my a portion of my program: #include <stdio.h> main() { int fahr, celsius; int lower, upper, step; int fc_conv(int fahr); ... snip ... }
7
by: Sheldon | last post by:
Hi, This is a simple mistake so Iam sure there is someone who can help with it: The the file.h: #define IBFLEN 50000 int IRET, ILEN, IUNIT1, IUNIT2, ILOOP, KERR;
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.