Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to remove hyperlink

Status
Not open for further replies.

London12345

Programmer
Jun 30, 2011
5
GB
I have a dynamic number like Reference:12345 the 12345 is having hypelink and near the number there is a delete button.When I click delete button the hyperlink should removed and just number should be displayed with out the hyperlink.

please advise how can we do this.
 
Hi

I have the feeling your requirement is an insignificant piece in a bigger thing, so I do not expect this to actually work for you.
JavaScript:
[b]function[/b] [COLOR=darkgoldenrod]unlinkify[/color][teal]([/teal]what[teal])[/teal]
[teal]{[/teal]
  [b]var[/b] link[teal]=[/teal]what[teal].[/teal]parentNode[teal].[/teal][COLOR=darkgoldenrod]getElementsByTagName[/color][teal]([/teal][green][i]'a'[/i][/green][teal])[/teal]
  [b]for[/b] [teal]([/teal][b]var[/b] i[teal]=[/teal][purple]0[/purple][teal],[/teal]l[teal]=[/teal]link[teal].[/teal]length[teal];[/teal]i[teal]<[/teal]l[teal];[/teal]i[teal]++)[/teal] [teal]{[/teal]
    [b]var[/b] text[teal]=[/teal]document[teal].[/teal][COLOR=darkgoldenrod]createTextNode[/color][teal]([/teal]link[teal][[/teal]i[teal]].[/teal]innerHTML[teal])[/teal]
    what[teal].[/teal]parentNode[teal].[/teal][COLOR=darkgoldenrod]replaceChild[/color][teal]([/teal]text[teal],[/teal]link[teal][[/teal]i[teal]])[/teal]
  [teal]}[/teal]
[teal]}[/teal]
HTML:
[b]<form[/b] [maroon]action[/maroon][teal]=[/teal][green][i]"#"[/i][/green][b]>[/b]
[b]<div>[/b]Reference:[b]<a[/b] [maroon]href[/maroon][teal]=[/teal][green][i]"#"[/i][/green][b]>[/b]12345[b]</a>[/b] [b]<input[/b] [maroon]type[/maroon][teal]=[/teal][green][i]"button"[/i][/green] [maroon]value[/maroon][teal]=[/teal][green][i]"Delete"[/i][/green] [maroon]onclick[/maroon][teal]=[/teal][green][i]"unlinkify(this)"[/i][/green][b]></div>[/b]
[b]<div>[/b]Reference:[b]<a[/b] [maroon]href[/maroon][teal]=[/teal][green][i]"#"[/i][/green][b]>[/b]67890[b]</a>[/b] [b]<input[/b] [maroon]type[/maroon][teal]=[/teal][green][i]"button"[/i][/green] [maroon]value[/maroon][teal]=[/teal][green][i]"Delete"[/i][/green] [maroon]onclick[/maroon][teal]=[/teal][green][i]"unlinkify(this)"[/i][/green][b]></div>[/b]
[b]</form>[/b]
As you posted no sample, I made up the rules :
[ul]
[li]the link and the related button has to be children of the same element[/li]
[li]all [tt]a[/tt] children of the parent are transformed to plain text[/li]
[/ul]


Feherke.
 
Thanks for your reply.

My requirement is near to this code there needs to be a delete icon cross mark(not button)and when click that icon the hyper link needs to be removed.

<td class="smallText"><b><u><font color="red">DUPLICATE ENQUIRY</font></u></b> -- Ref. Enquiry No:<div><a href="viewEditEnquiry.do?enquiryNo=<c:eek:ut value="${enquiryFormBean.refEnquiryNo}" />"> <c:eek:ut value="${enquiryFormBean.refEnquiryNo}" /></a>&nbsp;&nbsp;&nbsp;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top