# :delete =\> Button, link and javascript...how can i do this?

**URL:** <https://www.ruby-forum.com/t/delete-button-link-and-javascript-how-can-i-do-this/92009>\
**Category:** Rails\
**Created:** [April 14, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/delete-button-link-and-javascript-how-can-i-do-this/92009 "2007-04-14T13:24:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [April 14, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/delete-button-link-and-javascript-how-can-i-do-this/92009/1 "2007-04-14T13:24:49Z")

</div>

hi, i’m in a restful mode and i’ve a delete link. In this case i want to  
use a link, because i like it more than a button, but to do a delete  
method the user should have javascript actived…otherwise it won’t  
work… so, how can i show the link when javascript is actived and a  
button in the other case? or there is another method to do it simple and  
always with a link?  
thanks

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [April 15, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/delete-button-link-and-javascript-how-can-i-do-this/92009/2 "2007-04-15T23:43:54Z")

</div>

john wrote:

> hi, i’m in a restful mode and i’ve a delete link. In this case i want to  
> use a link, because i like it more than a button, but to do a delete  
> method the user should have javascript actived…otherwise it won’t  
> work… so, how can i show the link when javascript is actived and a  
> button in the other case? or there is another method to do it simple and  
> always with a link?  
> thanks

anyone? ☹

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [April 16, 2007, 12:09am UTC](https://www.ruby-forum.com/t/delete-button-link-and-javascript-how-can-i-do-this/92009/3 "2007-04-16T00:09:17Z")

</div>

I’ve never tried this, but how about:

function setButtonToLink()  
{  
$(‘yourButtonId’).replace(’ path/you/want/to/link/to your link ');  
}

function onLoad()  
{  
setButtonToLink();  
}

If js is not enabled, the button would be a button. If js is enabled, it  
would be replaced with your link.

Right?

David S.-2 wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
View this message in context:  
[http://www.nabble.com/%3Adelete-%3D\>-Button%2C-link-and-javascript...how-can-i-do-this--tf3575862.html#a10007306](http://www.nabble.com/%3Adelete-%3D%3E-Button%2C-link-and-javascript...how-can-i-do-this--tf3575862.html#a10007306)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [April 16, 2007, 5:40pm UTC](https://www.ruby-forum.com/t/delete-button-link-and-javascript-how-can-i-do-this/92009/4 "2007-04-16T17:40:17Z")

</div>

Steve R. wrote:

> I’ve never tried this, but how about:
> 
> function setButtonToLink()  
> {  
> $(‘yourButtonId’).replace(’ path/you/want/to/link/to your link ');  
> }
> 
> function onLoad()  
> {  
> setButtonToLink();  
> }
> 
> If js is not enabled, the button would be a button. If js is enabled, it  
> would be replaced with your link.
> 
> Right?

thanks, i’ll try 🙂
