cancel
Showing results for 
Search instead for 
Did you mean: 

Combination of onclick and on client click event of push button

Former Member
0 Kudos

Hi,

i have 6 input fields in the first page of bsp,in that iam having a particular field namely customer number.

and it contains search help.

my reqiurement is that the user can enter any of the other five fields and if he presses the help value for customer it should get the help values respect to the given value of those fields.

so what i did was i have created a pushbotton and uploaded the values using cookies of first five fields which user inputs to the customer search screen and retrived with respect to that.

but now the issue was the user needs to click on the pushbotton as well as the search help button on customer number.

so inorder to overcome this i have called the script code of search help customer number in the same push button.ie the onclick event of that pushbutton will trigger on input event and on client click will trigger the script code and now iam getting the search help of customer with respect to the inputed value

the only issue is the user need to click the pushbutton twice .

Can anybody suggest me how to trigger the both events simultaneously inorder to the avoid the user action twice?

Thanks

Nehru.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi all,

Thanks for all your useful answers,

Now i able to populate the value on search help screen for customer based upon the company code input but one issue iam facing still now was,i couldn't able to frame the syntax for other five fields in a similar way

kindly see the code below.

function getkunnr()

{

var url = 'Cust omer.htm?p_bukrs=' + docume nt.getElem entById("p_bukrs").value

docu ment.open( url, 'custlist', "height=500 width=400 left=420 top=150 stsus=no")

}

similar to company code i need to pass other 3 fields such as

name(p_name),city(p_cty),country(p_cnty).

example : 'Cust omer.htm?p_na me=' + document.getElementById("p_name").value

Can anyone help me out on this issue.

Thanks ,

Nehru

former_member184111
Active Contributor
0 Kudos

Hi Nehru,

To pass URL parameters in JS see the below code:

var name=document.getE lemen tById('p_name') .value
var city=document.getE lemen tById('p_city') .value
var countyr=document.getE lemen tById('p_ciuntry') .value


window. o pen('preview.htm?name='+name+'&city='+city+'&country='+country+'&end' , 'custlist' ,  "height=500 width=400 left=420 top=150 stsus=no")

Regards,

Anubhav

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi all,

Thanks for all ur useful answers , i got the solution and provided points.

Thanks Anubhav.

Regrads,

Nehru

Former Member
0 Kudos

Hi Anubhav,

Thanks for ur response.

But i couln't able to resolve that issue and even now it works on a double click.

Regards,

Mathan.

former_member184111
Active Contributor
0 Kudos

Hi Nehru,

I dont think both events can be trigered simultaneously but you can triger both events using a single click only .

in the OnInpurprocessing event handler,when your first button is clicked

onclick of first button

flag = 'X' .

in layout..

<%
IF flag = 'X' .
%>
<s cript>
document.getElement By Id('id of second pushbutton').cli c k() ;
</s cript>
<%
CLEAR flag .
ENDIF.%>

Regards,

Anubhav

Former Member
0 Kudos

Hi Anubhav ,

Kindly find the code below.

script code.

<s cript type = "text/ja vascript">

f unct ion transf_c omp any(fval)

{

d ocume nt.getE lem entById("P_BUKRS").value = fval;

}

func tion getb ukrs()

{

docu me nt.open('Compa nycode.htm', 'comlist', "height=500 width=400 left=420 top=150 stsus=no")

}

<%

IF flag = 'X' .

%>

<s cript>

do cument.getEle ment By Id('p_kunnr').cli c k() ;

</s cript>

<%

CLEAR flag .

ENDIF.%>

</sc ript>

<scr ipt type = "text/ja vascript">

func tion transf_custo mer(fval)

{

docu ment.getElementById("P_KU NNR").value = fval;

}

functi on getkunnr()

{

doc ument.open('Custo mer.htm', 'custlist', "he ight=500 width=400 left=420 top=150 stsus=no")

}

</s cript>

Thanks Nehru.

Former Member
0 Kudos

Hi Anubhav,

kindly find the code for layout on main page.

code for input field and pushbutton.

<h tmlb:bu tton text = "Search"

id = "2"

onC lick = "btn_event" />

<ht mlb:inp utField id = "P_KUNNR"

max length = "10"

siz e = "10"

va lue = "<%= p_kunnr %>"

sh owHelp = "X"

on ValueHelp = "getkunnr()" />

and i have set the falg = 'X' on pai event.

Requirement: when the user enters the company code and presses the pushbutton search the customer search help should be populated with respect to that.so as soon as the user enters the company code and other criteria's i have uploaded the values to the customer search help page through cookie's and retrived according to that.but now the user has to click the search pushbutton twice inorder to uploaded data and retrieve it from customer search help screen.

Please provide me a solution.

Thanks Nehru.

former_member184111
Active Contributor
0 Kudos

Hi Nehru,

Sorry but i did not get the problem completely.You created a search help for the field "P_KUNNR" so when the user clicks this value help button it trigers a JS function that opens a window with the required values...after this why are two clicks required can you please explain step by step..

Regards,

Anubhav

Former Member
0 Kudos

Hi anubhav,

Thanks for looking into this!

As you mentioned the respect values of the customer search help can be get trough the selecting values from the table if it is clicked.

but in my first page there are other input fields like customer name, city ,country etc.

so if the user enter these input values in the first page and presses the serach help of customer it should populate the values respect to that.

In order to perform this i have created a push button on the screen (search) , so if user gives the value for the other five fields and presses search pushbutton, the values are uploaded through cookies from the first page pai event and retrieved in the customer search help screen.

so if the user clicks the search pushbutton and then search help button of the customer , the program

will work fine according to the inputs .but now the issue was, the user dont want to click the two buttons.

so if the user clicks the search pushbutton or pushbutton on customer search help, the respective value should be shown in the search help screen.

Please let me know if iam not clear.

Thanks

Nehru.

Former Member
0 Kudos

Dear Nehru,

If you need search help for a particular field, it can be made.

If you need a search option by clicking on the Search button, the values given in the 5 fields will be validated and your operation can be performed.

But both can be done individually only and not in same event trigger.

Hope this will be helpful.

Regards,

Gokul.N

former_member184111
Active Contributor
0 Kudos

Hi Nehru,

If i am correct you need to simulate the click of the value help pushbutton on click of the search button.

Try the below code..

IF flag = 'X' .
%>

</sc ript>
<scr ipt type = "text/ja vascript">
func tion transf_custo mer(fval)
{
docu ment.getElementById("P_KU NNR").value = fval;
}
functi on getkunnr()
{
doc ument.open('Custo mer.htm', 'custlist', "he ight=500 width=400 left=420 top=150 stsus=no")
}

<%
CLEAR flag .
ENDIF.%>

So as soon as you click the search button , after all the validations the search help window will open up without clicking the value help button that appears next to the inputfield...

Regards,

Anubhav

Former Member
0 Kudos

Hi Anubhav,

Thanks for ur response but iam getting the page error if i paste the code like below.

<sc ript type = "text/ja vascript">

functi on transf_company(fval)

{

docu ment.getElementById("P_BU KRS").value = fval;

}

func tion getb ukrs()

{

documen t.open('Compan ycode.htm', 'comlist', "height=500 width=400 left=420 top=150 stsus=no")

}

<% if v_flg = 'X'.%>

</scr ipt>

<scr ipt type = "text/jav ascript">

functi on transf_customer(fval)

{

docu ment.getEleme ntById("P_KU NNR").value = fval;

}

func tion getku nnr()

{

docum ent.open('Custom er.htm', 'custlist', "height=500 width=400 left=420 top=150 stsus=no")

}

</sc ript>

<%

CLE AR v_flg .

END IF.%>

Plz check the above syntax for the script code coz iam getting error on main page after executing the program ,if i set the flag like above and if i remove these flag condition the program execute successfully.

Thanks & Regards,

Nehru.

Former Member
0 Kudos

Hi Anubhav,

i have also declared the v_flg as parameters in page attributes and set v_flg = 'X' in pai event of first page.

Thanks & Regards,

Nehru

former_member184111
Active Contributor
0 Kudos

Hi Nehru,

Try this code...

<% if v_flg = 'X'.%>
<scr ipt type = "text/jav ascript">
functi on transf_customer(fval)
{
docu ment.getEleme ntById('P_KU NNR').value = fval;
}
func tion getku nnr()
{
window. open('Custom er.htm', 'custlist', "height=500 width=400 left=420 top=150 status=no");
}

</sc ript>
<%
CLE AR v_flg .
END IF.%>

What is the error you are getting?

Regards,

Anubhav

Former Member
0 Kudos

Hi Anubhav,

i have just got the messege 'error on page' when i press any button on the first page after executing the program.and its working fine when i removed the flag conditions.

plz find the below code,

<% if v _fl g = 'X'.%>

</s cript>

<sc ript type = "text/jav ascript">

func tion transf_customer(fval)

{

docu ment.getEle mentById("P_KU NNR").value = fval;

}

func tion ge tkunnr()

{

docume nt.open('Custom er.htm', 'custlist', "height=500 width=400 left=420 top=150 stsus=no")

}

</sc ript>

<% if v _ flg = 'X'.%>

<% cle ar v_flg.

en dif.%>

its working fine if i remove the below conditions.

<% if v _flg = 'X'.%>

<% cle ar v_flg.

en dif.%>

Thanks & Regards,

Nehru.

Former Member
0 Kudos

Hi Anubav,

I have just got the messege 'error on page' when i press any button on the first page after executing the program.and its working fine when i removed the flag conditions.

plz find the below code,

<% if v _fl g = 'X'.%>

<sc ript type = "text/jav ascript">

func tion transf_customer(fval)

{

docu ment.getEle mentById("P_KU NNR").value = fval;

}

func tion ge tkunnr()

{

docume nt.open('Custom er.htm', 'custlist', "height=500 width=400 left=420 top=150 stsus=no")

}

</sc ript>

<% cle ar v_flg.

en dif.%>

its working fine if i remove the below conditions.

<% if v _flg = 'X'.%>

<% cle ar v_flg.

en dif.%>

Thanks & Regards,

Nehru.

former_member184111
Active Contributor
0 Kudos

Hi Nehru,

Are these javascript functions mentioned in code by you , being used / called by any other elements / conditions in the code?

Anubhav

Former Member
0 Kudos

Hi Anubhav,

it was a new object which i was created as per the client reqiurement , so there is no possibility of calls from different program and all the script code done by me, but i didn't understand by this flag check is showing error on page.

i didn't know whether we can check conditions and run the script according to that ?

Thanks

Nehru

former_member184111
Active Contributor
0 Kudos

Hi Nehru,

i didn't know whether we can check conditions and run the script according to that ?

Guess you are correct on this..so we wil take a javascript variable and set its value according to our abap variable v_flg..

Try this code..

<scr ipt type = "text/jav ascript">
var v_flg = "<%= v_flg %>";

if (v_flg=='X')
{
functi on transf_customer(fval)
{
docu ment.getEleme ntById('P_KU NNR').value = fval;
}
func tion getku nnr()
{
window. open('Custom er.htm', 'custlist', "height=500 width=400 left=420 top=150 status=no");
}
}
</sc ript>
<%
CLE AR v_flg .
END IF.%>

Anubhav

Former Member
0 Kudos

Hi Anubhav,

i have tried as mentioned as by u and now it doesn't shows any error but even now it works only on doulble click.what i understood was,

The control first goes to the onclientclick and the script triggers as a result of onclient click and then

it sets a flag on pai event of first page.so when we click on second time the value which has been transfered already on the first click retrieve's the value for search help page and the exact value triggers on the output

The code for search button on first page

<ht mlb:button text = "Sea rch"

id = "2"

onCl ick = "btn_event"

onClie ntClick = "getku nnr()" />

is there any other way to get the search help values for a particular field with respect to the screen inputs on the same page?

Thanks

Nehru.

athavanraja
Active Contributor
0 Kudos

here is a simple solution explained in a test app.

create a bsp application and create two pages, say main.htm and pop.htm.

in main.htm layout enter the following code.


<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>

<htmlb:content design="design2003">
<sc ript>
function vhelp()
{
var myur = 'pop.htm?carrid=' + docum ent.getEle mentById('I1').value;
window.open (myur, '_blank', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=550,left = 362,top = 234')
}
< /sc ript>
  <htmlb:page title = " ">
    <htmlb:form>
<htmlb:inputField id="I1"
                  value="AA"/>
<htmlb:inputField id="I2"
                  showHelp = "true"
                  onValu eHelp="vhelp();"/>

    </htmlb:form>
  </htmlb:page>
</htmlb:content>

and in the pop.htm create a page attribute called "carrid" type string with "auto" check box checked.

and enter the following code in the pop.htm layout


<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
<sc ript>
 function proce sssel(val)
 {
 wind ow.ope ner.docu ment.getEle mentById('I2').value = val ;
 sel f.clo se();
 }
< /sc ript>
  <htmlb:page title=" " >
    <htmlb:form>
      <%
  data: contab type standard table of string ,
  wa type string .
  data: car type S_CARR_ID .

  car = carrid .
  select connid from SPFLI into table contab where carrid = car  .
  if not contab[] is initial .
  loop at contab into wa.

      %>
      <a href="#" oncl ick="processsel('<%=wa%>')"><%=wa%></a> <br>

      <%
  endloop .
  endif .
      %>
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

activate the app and the pages and run main.htm for testing.

Hope this helps.

Regards

Raja

former_member184111
Active Contributor
0 Kudos

Hi Durairaj,

I tested the code provided by you by creating an application exactly as mentioned by you..

but i am getting the following error..

BSP Exception: The object pop.htm in the URL / sap (bD1lbiZjPTIwMA ==) / bc / bsp / sap / ztest_events / pop.htm? Carrid = AA is not valid.

Regards,

Anubhav

athavanraja
Active Contributor
0 Kudos

have you activated the pop.htm page

former_member184111
Active Contributor
0 Kudos

Hi Raja,

I wrote

var myur = 'popup.htm?

instead of

var myur = 'pop.htm?

Its working perfectly now..

Thanks a lot,

Anubhav