Click to See Complete Forum and Search --> : Populating a text box with the value of a variable


mblack
02-18-2003, 12:56 PM
Does anyone know how to populate a text box with the value of a variable. I am pulling in values from a cookie created in a previous page and want to populate a textbox with the value the user entered and give them the chance to change it before submitting to the checkout and the database.
....
<tr height="10">
<td></td>
<td><b>Change or Delete order&nbsp;</b><input type="text" size="20" name="alterProduct" value="value of variable goes here"></td>
</tr>
....

I have tried several things such as creating a function in which I assigned the value of the variable to the value of the actual text box, which did not work.
....
document.formName.textboxName.value = desiredVariable
....

Can anyone shed some light on the problem I am having? Any help would be appreciated.

Thanks
mblack

gil davis
02-18-2003, 01:13 PM
This works for me:

<head>
<script>
var stuff = "this is some stuff";
function loadit() {
document.f1.t1.value = stuff;
}
</script>
</head>
<body onload="loadit()">
<form name="f1" onsubmit="return false">
<input type="text" name="t1">
</form>
</body>