cancel
Showing results for 
Search instead for 
Did you mean: 

javascript access to htmlb textEdit

Former Member
0 Kudos

Hi,

Since the htmlb object textEdit does not support javascript access through the jsObjectNeeded option I tried another approach.

This approach is mentioned several times on SDN but it does not perform as excepted.


<% String compID = null; %>


<hbj:textEdit 
id="reaction"
	text=""
	wrapping="SOFT"
	rows="5"
	cols="50">
	<%compID = myContext.getParamIdForComponent(reaction);%>
</hbj:textEdit>

<%=compID%>			(<-- test to write ID to html page)

This code retrieves the ID of the htmlb component. It works fine as I can write the htmlb ID to the html page.

However I need this ID in my javascript during a validation. The problem is that the ID is empty in the javascript.

Please help.

Raymond

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Raymond,

Try out the following piece of code (the code is tested and is working):

<hbj:textEdit 	id="addComments" 
			     wrapping="SOFT" 
			     text="" 
			     rows="2" 
			    cols="100" > 
						
	<% addComments.setJsObjectNeeded(true); %>
</hbj:textEdit>

Then through javascript you can access the id of the text edit in the similar fashion.

var txtAdCom= eval(func("addComments"));
var value =txtAdCom.getValue();
var length = txtAdCom.getValue().length;

Please do reward with points if the solution is helpful.

Thanks

Ritushree

Former Member
0 Kudos

Hi Ritushree,

Solved it myself this morning. I used:


var loDocForms = document.forms;
		
for( var i=0; i<loDocForms.length; i++ )
  {
      try
          {
                var funcName = document.forms<i>.id + "_getHtmlbElementId";
                func = window[funcName];
                var field = eval( func(id) );
			 	
                if(field)
                {
                     return field;
                }
          }
          catch( ex )
          {
           }
    }

Cheers,

Raymond

Former Member
0 Kudos

Hi Raymond,

If the problem has been solved please do mark the problem as solved.

Thanks

Ritushree

Former Member
0 Kudos

I guess u know the code to read the htmlb component in javascript..

function test(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var btnFld = eval(func("htmlb_btn_name"));

var txt_value = btnFld.getValue();

}

Former Member
0 Kudos

Because we use Btexx EasyWCM (content management tool for SAP portal) we use embedded Iviews. This result in several HTMLB form ID's in the html page.

If I use javascript: var funcName = htmlb_formid+"_getHtmlbElementId"; it seems to find the latest htmlb formid but not necessarily the correct formid.

I used:

 
var loDocForms = document.forms;
for( var i=0; i<loDocForms.length; i++ )
{
	try
	{
		var funcName = loDocForms.id + "_getHtmlbElementId";
		func = window[funcName];
		var field = eval( func(id) );
		
		if(field)
		{
				return field;
		}
	}
	catch( ex )
	{
	}
}

But this didnu2019t work either. Please let me know if there is a solution for this issue.

Raymond

Former Member
0 Kudos

Hi,

If nothing else works as a final solution you can do one thing. Define a java string txt="". Then assign the id of the text edit to this string txt and after this assign this as a value to a hidden input field which you will be able to access from javascript. Let me know if you have any issues with this.

Former Member
0 Kudos

Hi,

You can set jsObjectNeeded to true and use textedit. Check these links.

Regards,

Harini S

Former Member
0 Kudos

Hi Harini,

To my knowledge the textEdit object does not support jsObjectNeeded. When I try this I get a jsp error.

Have you been able to use this property yourself?

@ Juergen: The javascript is ok, the problem is that the jsp variable is null. So I have no htmlb id to use in javascript.

Please let me know if you have a solution to read the HTMLB ID in javascript.

Regards,

Raymond

Former Member
0 Kudos

Hi Raymond!

Please post the javascript code in question. I remember doing the exact same thing a few years ago but have no access to the code anymore. Maybe I can patch something up by reviewing your code.

Regards,

Jürgen