bo*****@gmail.com wrote:
Currently, I am having a problem replacing the value of a input box
with something else using the innerHTML thing. Right now I have
something going
<script type="text/javascript"><!--
Do not use HTML-style comments inside script elements, they are a
complete waste of time.
function changeText(newText){
document.getElementById("WHATEVER").innerHTML=newT ext
innerHTML is proprietary DOM element property introduced by IE. It has
been widely copied (though inconsistently) and represents the HTML
between the start and end tags of an element - i.e. it's HTML content.
}
//-->
</script>
and a link with
<a href='javascript:changeText("Hola Mi Amigo")'>Dont know</a>
Using the javascript pseudo-protocol as the value of an href attribute
is a bad idea. If you want to use an A element, use an onclick
attribute with return false to cancel navigation:
<a href="#" onclick="changeText('Hola Mi Amigo');return false;">Dont
know</a>
and the text box like
<INPUT TYPE="TEXT" NAME="WHATEVER" id="WHATEVER" VALUE="TESTING"
SIZE=60">
As noted above, the innerHTML property of an element represents its
HTML content. Since INPUT elements don't have any content, it's
difficult to say what the browser will make of assigning some HTML to
its innerHTML property. There is no public specification that says how
to handle it, so implementations may differ.
It is likely, but not guaranteed, that they will simply ignore it.
If you are trying to change the text that appears in the text input,
then change the input's value attribute.
and I am trying to replace what is enterd in the text box with "Hola Mi
Amigo." However, it doesnt seem to want to do it. Maybe I am doing
something wrong, but I have no idea what my problem is.
<a href="#" onclick="
document.getElementById('WHATEVER').value = 'Hola Mi Amigo';
return false;
">Dont know</a>
Feature detection omitted for brevity.
--
Rob