PDA

View Full Version : How can I modify text via Javascript?


richb2
08-09-2002, 03:20 AM
I have a form that has a textbox on it. In the front of it I have a label, let's call it COMPANY. I want to be able to change the text of COMPANY to FIRM programatically. I have done some research and can't find a way to modify the text. One new idea is to use layers. ie

<LAYER ID="field1">COMPANY</LAYER>

I would like to write a function

function changeLayerContent(field,text)
{
field.write(text);
}

and call it by changeLayerContent(document.getElementById("field1"),"FIRM");

When I run this I get an error document.field1.document is not an object. What is wrong or how else can I do this?

x_goose_x
08-09-2002, 03:57 AM
<div id="mydiv">Hello</div>
<script>
document.getElementById("mydiv").innerHTML = "whatever";
</script>

richb2
08-09-2002, 04:03 AM
Thanks. I'll try it out. Where do I go to find properties like innerHTML?

x_goose_x
08-09-2002, 04:13 AM
Try DevGuru (http://www.devguru.com).

For javascript: http://www.devguru.com/Technologies/ecmascript/quickref/javascript_index.html