Jump to content

Making a Text Link act the Same as a Form Button


marcus

Recommended Posts

<script type="text/javascript">
function insert(el,ins) {
    if (el.setSelectionRange){
        el.value = el.value.substring(0,el.selectionStart) + ins + el.value.substring(el.selectionStart,el.selectionEnd) + el.value.substring(el.selectionEnd,el.value.length);
    }
    else if (document.selection && document.selection.createRange) {
        el.focus();
        var range = document.selection.createRange();
        range.text = ins + range.text;
    }
}
</script>

<form>
<input type="button" value="Quote This User" onclick="insert(this.form.reply,'[quote=username]their message[/quote]')">
<br />
<textarea rows="7" cols="30" name="reply"></textarea> 

 

Is what I'm trying to do, it make the input type="button" a normal a href="#" link, but act the same way as the input button.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.