Gossamer Forum
Home : General : Internet Technologies :

Fill-in form input-field based on value in hidden page

Quote Reply
Fill-in form input-field based on value in hidden page
 
Hi,

I'm looking for a simple javascript to do the following tric:

1) Open a (hidden) page based on a form-input field.
2) Retrieve a specialy prepared value form that hidden page
3) Display the retrieved value in a second input field.

Who can point me into a good direction/website? (There is (complicated) dutch example @ http://www.k7000.nl/register/form/ * which I don't understand Frown)

Regards,

cK

* Type in "1042AN" at "Postcode" (=ZIP-CODE) and see what happens... (Just after "Geef de eerste vertreklocatie van je auto op:") Isn't that cool?!

Last edited by:

cK: Jun 3, 2003, 8:29 AM
Quote Reply
Re: [cK] Fill-in form input-field based on value in hidden page In reply to
I'm not sure what you mean about retrieving a hidden page.
Quote Reply
Re: [Paul] Fill-in form input-field based on value in hidden page In reply to
I hope this helps...

1) The javascript on /page1.html should open /getfromdatabase.php?something=test
2) /getfromdatabase.php?value=test should output "value = 'testval;"
3) The javascript on /page1.html should put "testval" in the inputfield "something"

Is it more clear now? (Actually, visit the sample webste is the best to do!)

Last edited by:

cK: Jun 3, 2003, 8:34 AM
Quote Reply
Re: [cK] Fill-in form input-field based on value in hidden page In reply to
That's possible, but in order to get the value from the other URL, it will have to be opened as a new window - it can't be hidden...is that ok?
Quote Reply
Re: [cK] Fill-in form input-field based on value in hidden page In reply to
Quote:
(Actually, visit the sample webste is the best to do!)

Just looked but I just get dutch errors when I fill in the form...no idea what it's saying or doing Wink
Quote Reply
Re: [Paul] Fill-in form input-field based on value in hidden page In reply to
Just only fill in the "Postcode" field as above and move your mouse to another field.... You will see that the streetaddress and city are pre-filled inWink
Quote Reply
Re: [cK] Fill-in form input-field based on value in hidden page In reply to
Hehe got it =)

Ok here's the code...

Code:
function GetAddress(p_sFld){
if(
eval("document.frmRegister." + p_sFld + "Postcode.value.length >= 4") ||
eval("document.frmRegister." + p_sFld + "City.value.length > 0") ||
eval("document.frmRegister." + p_sFld + "Street.value.length > 0")
){
parent.adressen.location = funReplaceSpace("../../app/KR/adressenKR.asp?checksession=no&Postcode=" +
eval("document.frmRegister." + p_sFld + "Postcode.value") +
"&HouseNr=" + eval("document.frmRegister." + p_sFld + "HouseNr.value") +
"&Street=" + eval("document.frmRegister." + p_sFld + "Street.value") +
"&City=" + eval("document.frmRegister." + p_sFld + "City.value") +
"&Fld=" + p_sFld);
}
}

Last edited by:

Paul: Jun 3, 2003, 11:02 AM
Quote Reply
Re: [Paul] Fill-in form input-field based on value in hidden page In reply to
This is the code indeed Unsure

I was only looking for a simpeler version (or script or tutorial) to understand the code. Because I would like to implement this idea on my site and not copy-paste (=steal) the code. Sorry, if this wasn't clear. My fault! Next to this, the zipcode-database they are using is copyright protected Wink

(It's the eval part in combination with the retrieve part that I don't understand.)

This is the code that is returned on the hidden page:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>adressenKR</title><link href="../../tgstyle.css" type="text/css" rel="StyleSheet">
<script language="JavaScript" type="text/javascript">
parent.overzicht.document.forms[0].City.value = "AMSTERDAM";
parent.overzicht.document.forms[0].Street.value = "Postbus";
parent.overzicht.document.forms[0].Postcode.value = "1000AA";
</script></head><body></body></html>

Last edited by:

cK: Jun 3, 2003, 2:43 PM