Page 1 of 1

RESOLVED - Simple Javascript Form Problem

Posted: Mon Sep 13, 2004 8:21 am
by sell-traffic
Hi,

In a function within my head tags, I build a variable called orderinfo.

All I want is to set the value of one of my form textboxes to be this variable. Seems simple enough.

I've tried putting a "form.textbox.value = orderinfo" and that does nothing

I've tried putting a document.write for the javascript value inside the value="", and that does nothing.

Can someone guide me in the right direction?

Josh

Posted: Mon Sep 13, 2004 8:43 am
by CoderGoblin
1) This question should really should be in the Client Side forum not PHP Code.

2) OK why just javascript (Is this pure javascript or php as well) ?

Possible answer. Build the page (I assume the form has a name as well as the actual textbox).

On the body HTML tag have the following:

Code: Select all

<body onload="javascript:document.formname.textboxname.value=variablename;">
Disadvantage of this is that the value will overwrite the "POST" or "GET" variable.

This has been stated many times but I will reiterate it here.... Some users will DISABLE JAVASCRIPT. It makes more sense to have the server build all the necessary information which a user requires (PHP). Javascript can then be used to validate a form or do fancy things, but you need to already have the information from the server.

Posted: Mon Sep 13, 2004 8:46 am
by sell-traffic
OK, that makes sense, thanks.

Josh