0

How can I target another ID when the page reloads? For below example, from another page it will bring parameter and redirects to this page, if the parameter is "EM" the page will auto target the module "eMOTOR" .

https://test.e-cover.com.my/shk/test/test2.jsp

AsgarAli
  • 2,201
  • 1
  • 20
  • 32
user3835327
  • 1,194
  • 1
  • 14
  • 44

2 Answers2

0

You can put the parameter in query parameter eg:https://test.e-cover.com.my/shk/test/test2.jsp?target=EM. After that there are 2 options: (1) read it in the servlet and render class active to the tab or (2) do the same thing using js

EDIT

There may be a better way if you check the library doc, but you definitely can select the tab with jquery:

$('.search-box li').removeClass('active')
$('.search-box li').eq(1).addClass('active') // index 1 = eMOTOR

Of course it would be better if you add an id or class to the li, eg emotor:

$('.search-box li').removeClass('active')
$('.search-box li.emotor').addClass('active')
Community
  • 1
  • 1
Yohanes Gultom
  • 3,782
  • 2
  • 25
  • 38
  • i can get parameter , just have no idea how to use javascript to target the eMotor ID.. i tried the html dom target attribute, but failed.. – user3835327 Feb 23 '17 at 04:02
0

You can use a common class for example button and to get the id use e.target.id . To reload the url use window.location.replace

 $('.button').on('click', function(e){
  window.location.replace("https://test.e-cover.com.my/shk/test/test2.jsp?target="+e.target.id);
  //alert(e.target.id);    
});
Rafiqul Islam
  • 1,636
  • 1
  • 12
  • 25
  • i can get parameter , just have no idea how to use javascript to target the eMotor ID when the page is reload.. – user3835327 Feb 23 '17 at 04:23
  • See this [How to remain in the tab selected after reloading the page](http://stackoverflow.com/questions/35935169/how-to-remain-in-the-tab-selected-after-reloading-the-page) – Rafiqul Islam Feb 23 '17 at 04:47