I want to get Value from CodeMirror textarea whose name I have in Cookie. How can I do this?
I tried:
var formname = $.cookie("formname");
va开发者_JAVA技巧r formcode = formname.getValue();
Firebug says: formname.getValue is not a function
Thank you very much. I hope you understand me.
formname
is a string. A string does not have such a method called getValue
. Seeing the appearance of $.cookie("formname")
, I assume that you're using JQUery.
Code:
var formname = $.cookie("formname");
var formcode = $('textarea[name="'+formname+'"]').val(); //JQuery method:
// Selects an input element whose name equals `formname` and gets the value of it.
//var formcode = document.getElementById(formname).value;
// Another method: Without use of JQuery, assuming that the textarea's id equals formname
精彩评论