Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
How to get the fckeditor_textarea tag value
9 Posts
How to get the fckeditor_textarea tag value

Hi i was mentioned as in my view page is

'Easy', :width => '100%', :height => '200px') %>

how to get the value into javescript. Iwant to do javascript validations for this Please help me on this

Person
Forum Rating: 50
Sign In To Rate Post

Hi Lucky,

In the above case for the validation you can access element value by its ID.

for above syntax code will be like...

http://pastie.org/1015450

Try above function.. I hope it will help you.

Good Luck ;)

-Ganesh

Person
Jruby, Ruby, Rails Programmer
Sign In To Rate Post

Hi Ganesh ,

   Thanks for your response .It's not working .Could you please suggest other alternatives
Person
Forum Rating: 50
Sign In To Rate Post

lucky when you say its not working, please be more specific. See if you're getting any javascript errors. Use Firebug, that should help a lot.

Hi, i have given code in application.js is

alert('dsadsa'); var objFckEditor = getElementById('deal_head_line'); if(objFckEditor.value == "") {

alert("Head line cant be blank..");
return false;

} alert('1111')

My html code is 'Easy', :width => '100%', :height => '200px') %> while submiting form call the above jvascript code there giving alert('dsadsa'); only .didnot move to nextline

Please help me

Person
Forum Rating: 50
Sign In To Rate Post

Hi lucky..

just replace your following syntax..

var objFckEditor = getElementById('deal_head_line');

Use : var objFckEditor = document.getElementById('deal_head_line');

I hope it will work for this time.. I usually work with jQuery so not that good in simple javascript..

For more information and syntax of js follow this ( http://www.w3schools.com/js/default.asp ) tutorial.

Good Luck ;)

-Ganesh

Person
Jruby, Ruby, Rails Programmer
Sign In To Rate Post

Hi ganesh , i have used var objFckEditor = document.getElementById(‘deal_head_line’); still its returns "null" Even i entered value in headline

Person
Forum Rating: 50
Sign In To Rate Post

Hi,

Oops...!!! In that case you have to first identify that what exactly id get generating your fck textbox..

You can find id using firebug or using view source..!

I'm asking this Bcoz as you said that you are reaching up to following msg

alert(‘dsadsa’);

But I guess due to improper id which you mentioned in the var objFckEditor = document.getElementById(‘deal_head_line’); you caught that "null". So, please find what is id ofyour fck textbox.. then apply same id in getElementById()..

Don't mind but I guess you are new in the web-dev.. either should have to have clear all the basic of js, css and use of various browser and its related tool.. As programmer many times we get stuck up with these types issues but should have to learn these basics and imp is to learn tricks/techniques to resolve it.

Also post here if you find any alternative to resolve this issue.. So that it will be helpful for others issues..

Good Luck ;)

-Ganesh

Person
Jruby, Ruby, Rails Programmer
Sign In To Rate Post
9 Posts
Login to add your message