On Aug 18, 2010, at 11:51 AM, Erwin wrote:
I have the following html code in my page
li style=display: none; id=show_user class=basic_link
a href=/admin/users/4c6a275ea326cb01f401?locale=enShow
User/a
/li
I would like to modify the id part of the href
(4c6a275ea326cb01f401)
between the '/admin/users/' string and the '?locale=en' string (always
present) with the value of a variable: var id= selection[0].id;
I know that in order to get the element to be modified , I can write :
$('show_user').firstDescendant()
I would use var link = $('show_user').down('a');
but then .. I don't know how to modify it ..
Now that you have the existing link, and the new bit you want to
replace, it's just a matter of string splitting and re-assembly. If
the /admin/users/ part is always the same, you could do something
really simple like this:
(wrap this whole thing in a test for link's existence, so you don't
get bitten if the HTML changes later)
var new = '/admin/users/' + id + '?' +
link.href.toString().split('?').last();
and finally,
link.href = new;
and you're done.
Walter
any help will be welcome
erwin
--
You received this message because you are subscribed to the Google
Groups Prototype script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
.
To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com
.
For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en
.
--
You received this message because you are subscribed to the Google Groups Prototype
script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.