ckrudelux Posted October 5, 2009 Share Posted October 5, 2009 " theField = this "function clearText(theField) { if (theField.defaultValue == theField.value) theField.value = ''; }function addText(theField) { if (theField.value == '') theField.value = theField .defaultValue; } Okay so this script works on my page and at the same time it don't.I have to diffrent pages on the same server both have this script but only one of the pages got it working.The page that don't get this script runing as it should clears the text onfocus but onblur it don't get the text back.At one place where I use this script I get this text then I select the textarea after the input field with the script:[object HTMLInputElement]What is wrong?? No alerts from firebug... Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2009 Share Posted October 5, 2009 Show where you call those functions on the text elements. Link to comment Share on other sites More sharing options...
ckrudelux Posted October 5, 2009 Author Share Posted October 5, 2009 Show where you call those functions on the text elements.Here is one of them.<input title="skriv ett sök ord här." class="topinput" type="text" name="search" onblur="addText(this);" onfocus="clearText(this)" value="Sökord" /> Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2009 Share Posted October 5, 2009 Print out the value and default value in the addText function to see why it's not setting it. Link to comment Share on other sites More sharing options...
ckrudelux Posted October 5, 2009 Author Share Posted October 5, 2009 Print out the value and default value in the addText function to see why it's not setting it.I added an alert in the first row of the function and it don't even show up. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2009 Share Posted October 5, 2009 Do you have any other Javascript on the page that might be overwriting the onblur event? Link to comment Share on other sites More sharing options...
ckrudelux Posted October 5, 2009 Author Share Posted October 5, 2009 I added an alert in the first row of the function and it don't even show up.Okay I found the error I just made two functions with the same name. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.