0

hello,
I have this button element which i can recognize only through his xptah

FORM[1]/TABLE[1]/TBODY[1]/TR[1]/TD[2]/TABLE[5]/TBODY[1]/TR[1]/TD[1]/A[1]/IMG[1]

how can preform a click runing a java script

Thanks
Kobi

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Taywin
0

Do you use some kind of javascript library (e.g. prototype, jquery)?
If you use prototype, then you can click that button by something like this

var selector = new Selector('form > table:nth-child(1) > tbody > tr:nth-child(1) >td:nth-child(2) > table:nth-child(5) > tbody > tr:nth-child(1) > td:nth-child(1) > a:nth-child(1) > img:nth-child(1)');
var elements = selector#findElements(document.body);
elements[0].click();

Result should be array, so you need a first element of it.

Edited by Protuberance: n/a

0

If you are asking about Javascript, then add "onclick='A_JAVA_SCRIPT_FUNCTION()'" to the tag that you want it to perform a javascript script. If you are asking for "java" script, you are on the wrong forum.

In this case, I assume that the HTML element you need to add 'onclick' event is "img." So you should do is...

<img src="whatever" onclick="a_javascript_function(argument1, ...)">

I can't give you any more code because there is no more info from your post.

0

Do you use some kind of javascript library (e.g. prototype, jquery)?
If you use prototype, then you can click that button by something like this

var selector = new Selector('form > table:nth-child(1) > tbody > tr:nth-child(1) >td:nth-child(2) > table:nth-child(5) > tbody > tr:nth-child(1) > td:nth-child(1) > a:nth-child(1) > img:nth-child(1)');
var elements = selector#findElements(document.body);
elements[0].click();

Result should be array, so you need a first element of it.

No im not usin any kind of special library
any other sugestion?

0

Oh, I misunderstood what you said earlier... You are using Xpath to access the node. I have never used Xpath before and I am not sure how to modify node's attributes. From my quick search, function 'fn:replace(string,pattern,replace)' may be what you are looking for? Something like...

FORM[1]/TABLE[1]/TBODY[1]/TR[1]/TD[2]/TABLE[5]/TBODY[1]/TR[1]/TD[1]/A[1]/IMG[1][replace(@onclick,/.*/, "jsscript_function()")]

Just a guess though...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.