function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ferozkhanferozkhan 

Problem on Textarea while get the content information in textarea using javascript

Hi All,

 

I am try to get the content body information of the textarea using javascript or jquery.

 

 

<apex:inputTextarea value="{!event_badge__c.Name_Badge_Body__c}" id="event_badge_text" styleClass="event_badge_text" richText="true"/>

 

am using richText="true" didnt get any information using javascript.

 

var con = document.getElementById("j_id0:event_from:j_id5:j_id13:event_badge_text___Frame").contentWindow.document.body.innerHTML;    alert(con);

 

using this code only get first iframe content but i didnt get the content inforamtion of the textarea.

 

if any one have anu idea about this issue why its happening?

 

Thanks & Regards

Feroz

navneetnavneet

var con = document.getElementById("j_id0:event_from:j_id5:j_​id13:event_badge_text___Frame").contentWindow.docu​ment.body.innerHTML;    alert(con);

 

first thing you need to check Ids caz most of the ids are generated at runtime. Give the IDs munually to all the section.

 

It should be allowed by using simple var con= document.getElementById('someId').value; 

 

ferozkhanferozkhan

ThanQ for Reaply,

 

if am not using the attribute richText="true" your solution is correct but am using the attribute richText="true" they seems problem.

 

the richText editor have contain two iFrames means <iframes id="someid"><table><tr></tr><tr><td id="something"><iframe></iframe></td></tr></table></iframes>

 

am trying to get the content of the iframe using iframe id

like as 

 

var con = $("someid").contents().html();

alert(con);

 

it should display hole content of the iframe like as <table></table>

 

in the content body it have another iframe.

 

am trying to get the information of the inner iframe using this code it should be null.

 

var con = $("iframe").contents().find("iframe").html(); or $("iframe").contents().find("inner td some id").html();

alert(con);

 

it should be given an null value;

 

Thanks & Regards

Feroz

Edwin VijayEdwin Vijay

Try using the $Component global variable..

 

VF Code:
<apex:outputtext richtext="true" id="richtextcomp"/>
<apex:image url="{!$Resource.Minus_image}" onclick="switchMenu('{!$Component.richtextcomp}')">

<script>
function switch(a)
{
alert(document.getElementById(a).value());
}
</script>

 

ferozkhanferozkhan

Thanks for reaply,

 

am using the $Component global variable.

 

it should be display null value;

 

<apex:inputTextarea richtext="true" id="richtextcomp"> </apex:inputTextarea>
            <apex:image url="{!$Resource.loadingimage}" onclick="switchMenu('{!$Component.richtextcomp}')"></apex:image> <script> function switchMenu(a) {
               alert(a);
               alert(document.getElementById(a).value);
              alert(document.getElementById(a).innerHTML);
                } </script>

but getting same thing null value.

ferozkhanferozkhan

am using the $Component global variable.

 

it is display null value;

 

<apex:inputTextarea richtext="true" id="richtextcomp"> </apex:inputTextarea>
            <apex:image url="{!$Resource.loadingimage}" onclick="switchMenu('{!$Component.richtextcomp}')"></apex:image> <script> function switchMenu(a) {
               alert(a);
               alert(document.getElementById(a).value);
              alert(document.getElementById(a).innerHTML);
                } </script>

 

plz give any idea about this.

 

Thanks & Regards

Feroz khan

ferozkhanferozkhan

Hi all,

 

am getting alternate solution of the richtextarea using dojo richtext

 

<apex:stylesheet value="http://ajax.googleapis.com/ajax/libs/dojo/1.2.0/dijit/themes/tundra/tundra.css"/>
 <apex:stylesheet value="http://ajax.googleapis.com/ajax/libs/dojo/1.2.0/dojo/resources/dojo.css"/>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.2.0/dojo/dojo.xd.js"  djConfig="parseOnLoad: true"/>

<script type="text/javascript">
 dojo.require("dojo.parser");
 dojo.require("dijit.Editor");
 dojo.require("dijit.dijit"); 
 dojo.require("dijit._editor._Plugin");
 dojo.require("dijit._editor.plugins.AlwaysShowToolbar");
 dojo.require("dijit._editor.plugins.FontChoice");  // 'fontName','fontSize','formatBlock'
 dojo.require("dijit._editor.plugins.TextColor");
 dojo.require("dijit._editor.plugins.LinkDialog");
</script>
<script type = "text/javascript">  

 function getvalues(myValue)
 {  
     var c = dijit.byId('editor1').getValue(false);  
     alert(c);
 }
</script>

VF Code Here

<apex:pageBlockSection title="Wild Cards" collapsible="false" columns="1" >
             Use This Wild cards to include the information in the badge body
              <apex:selectlist value="{!event_badge__c.Name}"  size="1" style="width:150px" onchange="getvalues(this.value);" >             
                     <apex:selectOptions value="{!showFields}" />
              </apex:selectlist>&nbsp;&nbsp;&nbsp;
             <div class="tundra" style="background-color: #f5f5f5;width:725px;">
 <textarea id="editor1" dojoType="dijit.Editor" inheritWidth="false" plugins="['bold','italic','|','createLink','foreColor','hiliteColor',{name:'dijit._editor.plugins.FontChoice', command:'fontName', generic:true},'fontSize','insertImage','insertHorizontalRule']"    name="tmpTextString" rows="20" cols="45"
 onBlur="document.getElementById('{!$Component.descript}').value = dijit.byId('editor1').getValue(false)">{!event_badge__c.Name_Badge_Body__c}</textarea> <apex:inputHidden id="descript" value="{!event_badge__c.Name_Badge_Body__c}"></apex:inputHidden> </div> </apex:pageBlockSection>

   am using this code working fine but am facing brower compability .

 

   it is working on Firefox browser. but not working on chrome browser.

   what is the problem if any idea.

 

  Thanks & Regards

  FerozKhan

navneetnavneet

Check if there are any java script errors.

Check if you are getting proper ids or not ,document.getElementById('{!$Component.des​cript}').

ferozkhanferozkhan

Thanks for reaply

 

am doing same thing and get the proper id.but gettting null value.

Raj1961Raj1961

Try using niceEdit text area free editor.....it will resolve all ur issues.....