0

This is in IE7. It's a corporate setting, so not using IE7 is not an option. I'm stuck with it.

I have a textarea in a form:

<textarea name="details" id="details" cols="80" rows="20" onfocus="detailsPrompt('focus')">Enter New Details Here</textarea>

There is a javascript file called in the portion of the html:

<script type="text/javascript" src="askopss.js"></script>

In that javascript file is this function:

function detailsPrompt(taken) {
if ((taken === 'focus') && (document.getElementById('details').value==='Enter New Details Here')) {
document.getElementById('details').value='';
}
}

When I click in the textarea, I expect the value to clear out. Except, nothing happens and this error appears:

Line: 196 Char: 1 Error: Object expected Code: 0

line 196 corresponds to the line of HTML with the tag

I had this problem with another function that was being called "onload" and I solved that by moving the function to a different .js file and then calling that js file in its own tag at the end of the document. It's not a solution that works for an onclick event, however.

Any idea what the problem is?

edit: included suggestions below, but it still doesn't work.

1 Answer 1

2

This line:

detailsPrompt(taken) {

Should read:

function detailsPrompt(taken) {

While:

document.getElementById('details').value

won't find your textarea because the textarea doesn't have an id.

Give the textarea an id attribute with the value details

That said, using a default value of a substitute for a <label> is a nasty hack with serious accessibility implications.

Sign up to request clarification or add additional context in comments.

2 Comments

leaving the function off was a dumb move on my part. I know better.
however, fixing that and giving it an id attribute didn't help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.