Bruce Gust
asked on
How can I clear the contents of a textarea with this function?
Here's my function:
Everything works just fine with the exception of the fact that I want to clear out whatever might be in the "homepage_text_one" field and replace it with "will I get this to work."
What's happening is that the user is backtracking. They've put a value in the "homepage_text_one" textarea, but now they're changing their minds as is evidenced by them having clicked on the radio button that triggers the above function.
What am I missing?
function spanishAlertYes(check)
{
//at this point, if the user clicks on this option, their changing their minds. If they said they needed a Spanish option, this will be checked by default.
//if they do change their minds, then everything they might've entered as far as "employee / spouse" values will be zeroed out and they'll be starting all over again as if they just completed their basic aesthetics
if(check.checked)
{
$('.submit_class').hide(100);
$('#submit_explanation').html("");
$('#emp_spouse_no').prop('checked', false);
$('#emp_spouse_yes').prop('checked', false);
$('.employer_options').show(100);
$(".employee_spouse_name").hide(100);
$('#homepage_text_one').html('will I get this to work');
}
}
Everything works just fine with the exception of the fact that I want to clear out whatever might be in the "homepage_text_one" field and replace it with "will I get this to work."
What's happening is that the user is backtracking. They've put a value in the "homepage_text_one" textarea, but now they're changing their minds as is evidenced by them having clicked on the radio button that triggers the above function.
What am I missing?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It was the "tinymce" dynamic that finally got it to work, but thanks for weighing in!
ASKER
I'm using a tinyMCE text editor. The code that clears the content from the text area is going to be:
tinyMCE.getInstanceById('h
See http://www.prettyscripts.com/free/tinymce-clear-field/ for reference.
Thing is, when I do that, I get an error:
employer_insert.php:404 Uncaught TypeError: tinyMCE.getInstanceById is not a function
at spanishAlertYes (employer_insert.php:404)
at HTMLInputElement.onchange (employer_insert.php:292)
After googling for something that might explain that error, I get some answers saying that I don't have the tinyMCE library loaded, but I do as is evidenced by the fact that you can see the texteditor.
My code looks like this:
Open in new window
Everything works except the "tinyMCE.getInstanceById('
Any ideas?