Forum OpenACS Q&A: Question about html area

Posted by Miguel Marin on
Does anyone know why when I submit a form that has one element of htmlarea doesn't captures the value that was written in. I'm having problems with this kind of things also when I have to htmlareas in the same form.

Any sugestions.

Posted by Jade Rubick on
Can you post example code? Generally, the more specific your question, the more likely people will be to respond to it.
Posted by Miguel Marin on
I wil try to explain it as well as I can:

I have a site that works well with Htmlarea, now I have a new applet were I will capture some information. The intention is to append the new capture text to the one that gives me the hrmlarea to put the two of them together in the DB.

I take out the original post button and made an extra form by my own like this

<form><input type=button  value=post onclick=post_mml();/>

To capture the text I made this javascript function that first capture the second applet text named equation and put it in a hidden message form field. The text that comes from the htmlarea is in the form message field content, so I alert the content value text but the doesnt appear, only does it when the htmlarea_p parameter is set to 0

function post_mml(action) {
    // This fetches the second applet text.
    mml_string = document.equation.getMathML();
    // This fill the hidden input content
    document.message.body.value = mml_string;
    // sets the hidden input action in the form message
    document.message.action.value = =\"post\"
    //submit the form

I hope I made myself clear.

Posted by Miguel Marin on
Dont pay attention to the action parameter in the javascript function, Its an error from when I was posting the message. Sorry
Posted by Torben Brosten on

It's been awhile since I've used javascript, but maybe "body" is a reserved word or buggy in this context:


Have you tried using a different input variable name?

Posted by Deds Castillo on

Dave asked me to look into this.  It's actually caused by several different things.  Here's a rundown.  Please try to apply it to your codebase and confirm so that necessary changes can be done on CVS as well.

1. htmlarea only copies to the form element when using its own submit button.  Fortunately, it has a method to get its contents -- objectname.getHTML() which should probably replace your document.message.content.value.  Lars used a global variable acs_blank_master__htmlareas which you can probably reference to get the object name.

2. The above will work on straight up integration, you can try it out by modifying /acs-templating/www/resources/htmlarea/example.html file.  But for OpenACS ATS there are some bugs that needs to be fixed to make it work.  This is because the htmlarea variable is passed to acs_initHtmlArea by value and not by reference making the calling page see the object as NULL instead of the actual htmlarea object.

I've fixed #2 on oacs-5-1 branch.

Posted by Deds Castillo on
Please try to apply it to your codebase and confirm so that necessary changes can be done on CVS as well.


Ignore this part. I initially thought it would require intrusive change. It was a backwards compatible 3 liner so I went ahead and did the commit so you can already update and just worry about #1.