textarea doesnt return value
Im using a code editor codepress in all of my textareas, but no textarea return a value. I think the different name and id is the problem. Exa开发者_如何学Pythonmple:
<textarea name="content_text" rows="20" cols="50" class="codepress sql" id="myCpWindow"></textarea>
I have read somewhere in here to use a hidden input to transfer the textarea's value, but i cant do it myself!
ayhelp?
Both answers didnt work...
In the support forum of codepress i found this:
<input type="submit" onclick="textareaID.textarea.value = textareaID.getCode();" value="save" />
but i cant understand.
Here is the link of discution
This worked for me.
If the name and id of the textarea are the same, it breaks the javascript. For the textarea i just assign an ID and I add a hidden input field with the name I wish to collect in the form process; then using the onsubmit to assign the codepress to the hidden input like this:
<form action="something" onsubmit="codeText.value = codeTextArea.getCode();">
<textarea id="codeTextArea" rows="20" cols="50" class="codepress java"></textarea>
<input type="hidden" name="codeText"/>
<input type="Submit">
</form>
You need to call textarea_id.getCode()
So you probably want something like this:
<form action="something" onsubmit="this.content_hidden = content_text.getCode();">
<input type="hidden" name="content_hidden">
<textarea name="content_text" rows="20" cols="50" class="codepress sql" id="myCpWindow"></textarea>
<input type="Submit">
</form>
no onsubmit you just need to turnoff the codepress
<form action="something" onsubmit="content_text.toggleEditor();">
<textarea name="content_text" rows="20" cols="50" class="codepress sql" id="myCpWindow">
</textarea>
<input type="Submit">
</form>
= drop the id.
Why are your names and id different? (you shouldn't do that in general btw). I assume you're using the name for your stuff and just taking the id because it was on their stuff. While i've never used codepress, most scripts like this (at least, well built ones) will build off of the class (and not the ID) so go ahead and drop the id and see if that works. cheers.
精彩评论