Thanks a lot, unfortunately the is number is not a static value ..
this is why I want to modify it when user selects a checkbox in a list

On 18 août, 19:00, greeny <[email protected]> wrote:
> On 18 Ago, 16:51, Erwin <[email protected]> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to