SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Link Maker

  1. #1
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Link Maker

    I'm trying to create something similar to VB's link maker. Where a user can click a form button, a window pops up and asks for the link name and url. Once user fills it in, It will add on some custom code to a form field:

    HTML Code:
    <script type="text/javascript" language="JavaScript">
    function make_link(field)
    {
    var text = prompt("Name of your link");
    var url = prompt("URL");
    
    document.forms.test.blah.field = document.forms.test.field.value + text;
    }
    </script>
    Obviously it doesn't work because I can't seem to figure out how I can specify the field to affect when I want to use this function.
    SK

  2. #2
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try:
    Code:
    <script type="text/javascript" language="JavaScript">
    function make_link(field)
    {
    var text = prompt("Name of your link");
    var url = prompt("URL");
    var link = "<a href='" + url + "'>" + text + "</a>"
    
    
    document.forms.field.value = document.forms.field.value +link;
    }
    </script>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •