Click to See Complete Forum and Search --> : write in textbox??


ddragas
01-06-2004, 03:35 PM
Hi all

I've got form and what I need is to write in textbox with data that I already have.

textbox is called "Sifra_smjestaja"
"firstname" is data that is needed to be writen in "Sifra_smjestaja"

Here is code

<!-- Begin
firstname = unescape(params["firstname"]);
document.write(" " + firstname + "<br>");
// End -->

Pittimann
01-06-2004, 03:40 PM
Hi!

If you tell us, where "params" is coming from, maybe we can help...

Cheers - Pit

fredmv
01-06-2004, 03:43 PM
Maybe a variable passed through the query string? As Pittimann already implied, it would be rather diffucult to help you out without seeing more code.

ddragas
01-06-2004, 03:43 PM
Params are comming from the other page. "Mother page"

I have downloaded and used code from link passing-values (http://javascript.internet.com/forms/passing-values.html) .

I'm getting value that I need wrom "mother" page. Now problem is to put it on "child page" in form in certan textbox

Pittimann
01-06-2004, 03:49 PM
Hi!

I already assumed that, fredmv, and it seems you're right, according to ddragas' last post!

Anyway, ddragas, can you post the code you already have??

Cheers - Pit

ddragas
01-06-2004, 03:51 PM
Here is code


<!-- THREE STEPS TO INSTALL PASSING VALUES:

1. Copy the form code into the first page with the form
2. Paste the HEAD code into the second HTML page
3. Add the final code into the BODY of your second page -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<BODY>

<center>
<form type=get action="passing-values-source.html">
<table border=1>
<tr>
<td>First Name:</td>
<td><input type=text name=firstname size=10></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type=text name=lastname size=10></td>
</tr>
<tr>
<td>Age:</td>
<td><input type=text name=age size=3></td>
</tr>
<tr>
<td colspan=2><input type=submit value="Submit!">
</td>
</tr>
</table>
</form>
</center>

<!-- STEP TWO: Paste this code into the HEAD of your second document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
// End -->
</script>
</HEAD>

<!-- STEP THREE: Put this on the page that should read the values -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
firstname = unescape(params["firstname"]);
lastname = unescape(params["lastname"]);
age = unescape(params["age"]);

document.write("firstname = " + firstname + "<br>");
document.write("lastname = " + lastname + "<br>");
document.write("age = " + age + "<br>");
// End -->
</script>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.23 KB -->

Pittimann
01-06-2004, 03:55 PM
Hi!

Sorry - did'nt see the post with the link.

Hoping, that you put the code properly into your page, you should use something like:

firstname = unescape(params["firstname"]);
document.forms[0].Sifra_smjestaja.value=firstname;

This should work, if there is only one form on the page, or - if not, the form is the first one...

Cheers - Pit

ddragas
01-06-2004, 04:12 PM
Sory but it doesn't work. Here I'm sending you file. Please help me if you can

Pittimann
01-06-2004, 04:28 PM
Hi!

I'm trying to give a careful statement: your code is a bit messed up - script tags all over the place (inside forms, tables, everywhere). For me , that's too chaotic for tonight.

I'll have a look at your thread tomorrow morning - hopefully, someone else will help you in the meantime...

Cheers - Pit

ddragas
01-06-2004, 04:30 PM
Thnx Pittimann

I really aprecheate your help.

ddragas
01-10-2004, 03:27 PM
anybody

PLEASE

Fang
01-10-2004, 03:35 PM
line 125 document.form1.Sifra_smjestaja.value=firstname;
You can not do this untill after the form(page) has loaded.
Put it in an onload="document.form1.Sifra_smjestaja.value=firstname;"

ddragas
01-10-2004, 03:41 PM
sorry but I'm complete begener.
In what line sholuld I put
onload="document.form1.Sifra_smjestaja.value=firstname;"

Thank you for your help

Fang
01-10-2004, 03:52 PM
This is easier for you: near line 118
<script language="JavaScript">
<!-- Begin
firstname = unescape(params["firstname"]);
document.write(' ' + firstname + '<br><input name="Sifra_smjestaja" type="text" id="Sifra_smjestaja" value="'+firstname+'">');
// End -->
</script>
</font></strong> </font></td>