Forum OpenACS Q&A: Question about html area

Collapse
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.

Collapse
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.
Collapse
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();/>
</form>

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\"
    alert(document.message.content.value);
    //submit the form
    document.message.submit();
    }

I hope I made myself clear.

Collapse
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
Collapse
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:

document.message.body.value

Have you tried using a different input variable name?

Collapse
Posted by Deds Castillo on
Miguel,

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.

Collapse
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.

Miguel,

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.