1

I think Its a very basic question. I am trying to develop a web page using Perl CGI. I have a text-editor(using iframe) in my form. Code:

<iframe id="textEditor" style="width:500px; height:170px;background-color:white">
</iframe>

I am trying to capture the content, which I am writing in text-editor on Submit of the form in my Perl CGI code, using param function. But failing!! Please help me out.

There is the code related to iframe:

<iframe id="textEditor" style="width:500px; height:170px;background-color:white">
</iframe>
<script type="text/javascript">
<!--
textEditor.document.designMode="on";
textEditor.document.open();
textEditor.document.write(\'<head><style type="text/css">body{ font-family:arial; font-size:13px; }</style> </head>\');
textEditor.document.close();
function def()
{
   document.getElementById("fonts").selectedIndex=0;
   document.getElementById("size").selectedIndex=1;
   document.getElementById("color").selectedIndex=0;
}
function fontEdit(x,y)
{
   textEditor.document.execCommand(x,"",y);
   textEditor.focus();
}
-->
</script>

I am trying to capture the value written in text-editor using CGI param() function.

1
  • 1
    Welcome to StackOverflow. For best results, show enough of your JavaScript and Perl code that what can understand how you are trying to pass the iframe content to the server and how the server script is trying to read it. Commented Aug 26, 2012 at 5:12

1 Answer 1

0

The client will only pass data from named <input>, <select> or <textarea> elements inside of a <form> element in your HTML. To pass back data from a JavaScript editor inside an <iframe>, you'll need to use JavaScript to set a value of an input element.

According to this tutorial, you'll want your HTML to look something like

<form name="myForm" action=".../my-cgi-script.cgi" method="POST">
    <input name="editorData" type="hidden" value="">
    ... other input elements ...
    <iframe id="textEditor" ...></iframe>
</form>

and you'll need some JavaScript like this to run when the submit button is pressed.

document.myForm.editorData.value = textEditor.document.body.innerHTML;
document.myForm.submit();

On the server side, the parameter editorData will then contain the contents of your text editor.

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

Comments

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.