Johnmitchell Posted October 3, 2006 Share Posted October 3, 2006 okay, before you say it i want this to work in I.E more than firefox, it's easy to get it to work in firefox but IE is a ****.at the moment, i have a text area with a default text of 'Type the entry here'. when they first load the page and click on the text box the text dissapears, and they can type whatever they want in the box. however when the user clicks away and clicks back on the text box all theire input vanishes!i want it so that when i click on the text area the default text dissapears, but the input from the user after the click stay there even when they click off the text area and back on.script: <script language="javascript" type="text/javascript"> function blankcontent (){ if (document.getElementById("txtContent").innerHTML = "Type the entry here...") document.getElementById("txtContent").innerHTML = "";} text box script: <form id="blogentry" action="createblog.asp?Message=update" method="get"><textarea id="txtContent" cols="80" name="txtContent" onfocus="blankcontent()" rows="10">Type the entry here...</textarea><br /></form> any ideas? driving me nutzcheers Link to comment Share on other sites More sharing options...
scott100 Posted October 3, 2006 Share Posted October 3, 2006 any ideas? driving me nutzcheers The problem is not IE it's your codeif (document.getElementById("txtContent").innerHTML = "Type the entry here...")Spot the error?You have only used one = sign not two ==To compair values you must use the double ==Correct codeif (document.getElementById("txtContent").innerHTML == "Type the entry here...") Link to comment Share on other sites More sharing options...
Johnmitchell Posted October 3, 2006 Author Share Posted October 3, 2006 Doh!!cheers scott - great help! :)way to go to get me feeling depressed at my coding skillz though Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 3, 2006 Share Posted October 3, 2006 Also, you might want to do it inline. It saves you space in your header section, and allows you to not have to make a new function <textarea id="txtContent" cols="80" name="txtContent" onfocus="if (this.innerHTML == 'Type the entry here...') this.value = ';'" rows="10">Type the entry here...</textarea>See if that works. Link to comment Share on other sites More sharing options...
reportingsjr Posted October 3, 2006 Share Posted October 3, 2006 Could you also use this.innerTEXT for this? I dont really get how you use .innerTEXT , can someone explain? Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 4, 2006 Share Posted October 4, 2006 innerText returns only the text inside a specific element.EXAMPLE:<p id="test"><b>zoop likes</b> monkeys with <u>butter</u></p>If you used this java script:<script type="text/javascript">x=document.getElementById("test");alert(x.innerText)</script>It would alert "zoop likes monkeys with butter". It basically strips out all formatting HTML from it and just returns the text.It can only be used in IE! For FireFox and Safari(not sure about Opera) use:alert(document.getElementById("test").textContent);Hope that helps.Choco Link to comment Share on other sites More sharing options...
scott100 Posted October 4, 2006 Share Posted October 4, 2006 Also, you might want to do it inline.Inline javascript / css has been depricated, external files are recommended But i don't think we want to go there....Hey we have a new guy -> Link to comment Share on other sites More sharing options...
Chocolate570 Posted October 4, 2006 Share Posted October 4, 2006 Deprecated, yet it still validates? What's with that? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now