cancel
Showing results for 
Search instead for 
Did you mean: 

reg java script

Former Member
0 Kudos

Hi all,

I have a tableview, i select a row and on clicking save im opening a window (using javascript) with some records, now if i select a row in the window, a particular value should get populated into a particular cell id of selected row in main tableview.

Can anyone suggest?

Thanks and Regards,

Sneha.

Accepted Solutions (1)

Accepted Solutions (1)

raja_thangamani
Active Contributor
0 Kudos

First Reply/Reward/Close below threads..

Regarding your question..Same issue discussed in detail in below thread...

<i>* Reward each useful answer</i>

Raja T

Former Member
0 Kudos

Hi,

In the thread given the window is opened for f4 help, so the row index and cell id for the f4 help is passed but in my case im opening window on save event, i could open window also but while passing back the selected, the value should be passed to a particular cell id.

Thanks and Regards,

Sneha.

Former Member
0 Kudos

Hi,

Since you are selecting a row and then pressing the save button, you can get the row-index by selectedrowindextable, and then if your column index is fixed then maybe you can hard-code the column index.

Hope this helps.

<i>Reward each useful answer..!</i>

Tatvagna.

Former Member
0 Kudos

Hi,

yes i have the selectedrow index and col, i did the samething but my problem is with javascript, the value i selected in window is not passing back to the given colid. I have used the following script in the window for function pass_data

opener.document.forms[0][colid].value = document.getElementById("partner").value;

Thanks and Regards,

Sneha.

Former Member
0 Kudos

Hi Sneha,

In my case what i am doing is using a javascript function setvalue

Then in the opened window...i am doing is

 opener.setvalue(cell_id)

Now the cell value of each cell is generated as follows :

suppose ur

tableView id is TV

then the cell value will be

'TV_' + 'rowindex' + '_columnindex'

so for first row, cell in 3rd column will have value <b>TV_1_3</b>

So you can just pass the value from the opened window and then concatenate selectedrowIndex and column index to generate cellid.....

And then you should be able to do it...!

Hope this helps...

<i><b>Do reward each useful answer..!</b></i>

Tatvagna.

Former Member
0 Kudos

Hi,

I have the coliid(cell id) stored in variable col, that is what im trying to populate from window using the code i have given, now i have changed the code to

opener.setvalue(col) = document.getElementById("partner").value;

but i could not pass back.

Thanks and Regards,

Sneha

Former Member
0 Kudos

Hi Sneha,

I am posting the code that I've used.

Please Refer and check if you find the error...

First : <b>In your iterator class~RENDER_CELL_START</b> :

  FIELD-SYMBOLS: <fs> TYPE ANY ,
                 <l_field> TYPE ANY.

  DATA: wf_text TYPE string .

  ASSIGN p_row_data_ref->* TO <fs>.

  CASE p_column_key.

    WHEN 'PLANETYPE' .

      ASSIGN COMPONENT p_column_key OF STRUCTURE <fs> TO <l_field>.
      IF <l_field> IS ASSIGNED .
        wf_text = <l_field> .
      ENDIF .

      CONCATENATE 'f4_TV(''' p_cell_id ''')' INTO javascript.

      col_inputfield = cl_htmlb_inputfield=>factory(
                                id        = p_cell_id
                                value     = wf_text
                                showhelp  = 'TRUE'
                                onvaluehelp = javascript
                                 maxlength  = '8').
      p_replacement_bee = col_inputfield.
  ENDCASE.

This will create an input Field in the table Value.

Now in <b>layout of calling page</b> :

<script>
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca<i>;
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function f4_TV(v1)
{
createCookie('CKE1',v1,1);
window.open("Zf4page_TV.htm","","left=300,top=220,width=220,height=400,menubar=1,scrollbars=yes,resizable=yes");
}

function setvalue(cell)
{
var myID = document.getElementById(readCookie("CKE1"));
myID.value = cell;

}

</script>

In the <b>Layout of called page : Zf4page_TV.htm </b>

<html>
<head>
<script language=Javascript>
var v2='';
var count=0;

function pass(cell)
{

    opener.setvalue(cell);

    window.close();
}

</script>
</head>

<body>
<p font-size=3 face=courier><b>Help Values</b></p>
<table border=1 border-color="#ff0000" bgcolor="#EFF6FB">
<tr><td>Sr. No</td><td>Plane Type.</td></tr>
<%  loop at html into html_wa. %>
<tr><td><%= sy-tabix %></td><td><a href="javascript:pass('<%= html_wa-PLANETYPE %>')"><%= html_wa-PLANETYPE %></a></td></tr>
<%
  endloop.
%>
</table>
</body>
</html>

Here html = itab

html_wa = wa

<i>Do reward each useful answer...!</i>

Thanks

<b>Tatvagna Shah</b>

Former Member
0 Kudos

Hi,

When the partner is selected now the window is closing but cellid is not getting populated with the selected value.

I have used the following code.

<script type="text/javascript">

{

acc ='<%= lv_account1 %>';

row ='<%= rw_idx %>';

col ="tv_"row"_5"

var s=0;

var r=1;

var w=260;

var h=100;

var x=screen.width/2;

x=x-w/2;

var y=screen.height/2;

y=y-h/2;

var val;

val = 0;

window.open('f4account2.htm?accnt='+acc,'_blank', 'Account Details','width=1000,height=420');

}

</script>

<script>

function setvalue(cell)

{

acc ='<%= lv_account1 %>';

row ='<%= rw_idx %>';

col ="tv_"row"_5"

var myID = col;

myID.value = cell;

}

</script>

in opener page and in popup i have used the following code.

<script language="JavaScript" type="text/javascript">

function pass(cell){

opener.setvalue(cell);

window.close();

}

</script>

on some condition:

<script type="text/javascript">

pass('<%= name_org %>');

</SCRIPT>

Pls correct me if im wrong anywhere.

Thanks and Regards,

Sneha.

eddy_declercq
Active Contributor
0 Kudos

Hi,

For the record, mixing ABAP variables with javascript is one useful when you want to initialize. One can't assign ABAP values during runtime.

Eddy

-


PS. Reward the useful answers and you will get <a href="http:///people/baris.buyuktanir2/blog/2007/04/04/point-for-points-reward-yourself">one point</a> yourself!

Former Member
0 Kudos

Hi Sneha,

First of all, just use one <script></script> tag for one page and write all the functions in the same tag....it is not wrong what you have done...but why take chances...

Also the code where you are generating col , you have not ended the statement with <b>;</b>

Then when you are concatenating the strings in <b>col</b>, it will be of type string, so i guess you will have to use <b>eval</b> function or something to make it realize that its a Object.....

Try using

col ="tv_"+row+"_5"
var myID = document.getElementById(col);
myID.value = cell;

<b>instead of</b>

col ="tv_"+row+"_5"
var myID = col;
myID.value = cell;

Also, I'm assuming that you've not copied the first function name in this thread...??

Also what Eddy said is very true...!

<i>Do reward each useful answer..!</i>

Thanks,

Tatvagna.

Former Member
0 Kudos

Hi,

I have tested the code if i use var myID = document.getElementById(col);the selected value itself is not passing, i donno what is the dependency here but if i use var myID = col;

then the value is passing back, i have checked this using alert(cell), the selected value from the window is passing back to 'cell' but i could not populate the myID.value with cell. if i put alert here its coming as undefined. also its showing the required cellid in alert(myID).

what does the function eval do?

Can you suggest something here?

Thanks and Regards,

Sneha.

Answers (0)