On 18 Ago, 16:51, Erwin <yves_duf...@mac.com> wrote: > I have the following html code in my page > > <li style="display: none;" id="show_user" class="basic_link"> > <a href="/admin/users/4c6a275ea326cb01f4000001?locale=en">Show > User</a> > </li> > > I would like to modify the id part of the href > (4c6a275ea326cb01f4000001) > 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() > > but then .. I don't know how to modify it .. > > any help will be welcome > > erwin
Hi I´m not an expert so this is a simple workaround. This will only work if "4c6a275ea326cb01f4000001" is a static value // some prevoius value var id= selection[0].id; //get the string from tue url var mylink=$('show_user').firstDescendant().getAttribute('href'); //replace '4c6a275ea326cb01f4000001' with id value mylink=mylink.replace( '4c6a275ea326cb01f4000001', id ); //set the new value to the url $('show_user').firstDescendant().setAttribute('href')=mylink; if "4c6a275ea326cb01f4000001" is a dynamic value one may as well use a similar process except that the url string has to be splitted into smaller parts and then filled with the proper values . Hope this can help you. -- 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.