Results 1 to 3 of 3

Thread: Fill a text box from a droplist

  1. #1
    Join Date
    Apr 2007
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Fill a text box from a droplist

    Hi, I wonder if anyone can help on this problem.

    I have a text box that users can type into, occasionally I want them to insert a preset bit of text (e.g. <<name>> or <<DoB>>) selected from a droplist.

    This will then be replaced with data from a database in a mailmerge type of thing which is why I need preselected text inserts. I can do the replacing bit fine (using PHP). I just can't work out the javascript for the other, inserting, bit.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Please post a link to the page on your site that contains the problematic script so we can check it out.

    Please include your code so that we can take a look at it, we can't do much without it.
    Jeremy | jfein.net

  3. #3
    Join Date
    Apr 2007
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Done it...

    I fiddled and played with a script I found and here is what I came up with.
    Seems to work exactly as I want so I thought I would post it in case it might help anyone else.
    It alows you to type and add preset text values (in my case field names for merging with a list).

    Code:
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="100%"><form name="merge_letter"><table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td width="100%"><select name="selectdatafield" size="1" onChange="addcontent(this)">
                <option selected >Select fields</option>
                <option value=" <<name>> ">Name</option>
                <option value=" <<DoB>> ">DoB</option>
                <option value=" <<class>> ">Class</option>
                <option value=" <<literacy>> ">Literacy</option>
              </select><br>
              </td>
            </tr>
            <tr>
              <td width="100%"><textarea rows="8" name="contentbox" cols="35" wrap="virtual"></textarea><br>
    <font face="arial" size="-2">This free script provided by <a href="http://wsabstract.com">Website Abstraction</a></font>
    </td>
            </tr>
          </table>
        </form>
        </td>
      </tr>
    </table>
    
    <script language="JavaScript">
    //Function to add words to a text area
    function addcontent(which){
    document.merge_letter.contentbox.value=document.merge_letter.contentbox.value+which.value
    }
    </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
  •