469,331 Members | 6,038 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

Help needed writing a Greasemonkey user script

MKR
I need some help writing a Greasmonkey user script. An application that
I use generates HTML pages with tags like this:

<input type="button" name="9999" value="1234567890"
onClick="showitem('1234567890'); return false">

Sometimes I just want to copy the item number (i.e. the "value"
attribute), other times I actually want to click the button and see the
item. Right now I can see the item number as a button label, but I
cannot copy its value. What I want to do is to use a Greasmonkey user
script to replace the buttons with some like:

<a href="./info/1234567890.htm">1234567890</a>

Can someone show me how to do that in JavaScript?

Many thanks.
Mar 1 '07 #1
1 1478
MKR wrote:
<input type="button" name="9999" value="1234567890"
onClick="showitem('1234567890'); return false">

Sometimes I just want to copy the item number (i.e. the "value"
attribute), other times I actually want to click the button and see the
item. Right now I can see the item number as a button label, but I
cannot copy its value. What I want to do is to use a Greasmonkey user
script to replace the buttons with some like:

<a href="./info/1234567890.htm">1234567890</a>
// assuming that input type="button" is the first element with
// that name 9999:
var button = document.getElementsByName('9999')[0];
if (button != null) {
var link = document.createElement('a');
link.href = './info/' + button.value + '.htm';
link.appendChild(document.createTextNode(button.va lue));
button.parentNode.replaceChild(link, button);
}
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 1 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Johnny Knoxville | last post: by
3 posts views Thread by Csaba Gabor | last post: by
27 posts views Thread by Scott | last post: by
6 posts views Thread by Jim Wooseman | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.