Onchange drop down menu help

Discussion in 'JavaScript' started by die4once, Sep 15, 2009.

  1. #1
    Hey I need some help with this code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Topic Tags</title>
    </head>
    
    <body>
    <table width="550px" >
      <tr>
        <td width="149">{L_SUBJECT}</td>
        <td width="550"><form id="form1" name="form1" method="post" action="">
          <input name="subject" type="text" id="subject" size="550px" maxlength="84" />
        </form>    </td>
      </tr>
      <tr>
        <td>Topic Tags</td>
        <td><select name="Topic Tags" onchange="document.getElementById('subject').focus(); document.getElementById('subject').value = this.options [this.selectedIndex].value + document.getElementById('subject').value;">
    <option selected value="">No Tag</option>
    <option value="[HELP]">[Help]</option>
    <option value="[SOLVED]">[Solved]</option>
    
    <select/></td>
      </tr>
    </table>
    
    </body>
    </html>
    Code (markup):
    At the moment when I select an option the text appears in the text box, but if I select another option with it the text appears in front of the text selected first.

    E.g "[SOLVED][HELP](Typed text)"
    I Selected help then solved.

    I need it to be after the text can any of you help me??????


    I've tried changing this:
    [this.selectedIndex].value + document.getElementById('subject').value
    Code (markup):
    To this:
    document.getElementById('subject').value + [this.selectedIndex].value
    Code (markup):
    But means if I type in the box before selecting the options, the options appear after the text I have just typed.
    E.g "(Typed text)(Selected Options)"

    BTW its for Phpbb forum
    Sorry i'm a n00b.
     
    die4once, Sep 15, 2009 IP
  2. prasanthmj

    prasanthmj Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #2
    make it subject = subject + option (as shown below)
    
    <select name="Topic Tags" onchange="document.getElementById('subject').focus(); document.getElementById('subject').value = document.getElementById('subject').value+this.options [this.selectedIndex].value;">
    
    Code (markup):
     
    prasanthmj, Sep 15, 2009 IP
  3. die4once

    die4once Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have tried this but if someone types in the subject in first the topic tags are added after what they just typed not before.
    E.g
    "(typed subject)[HELP][SOLVED]"
     
    die4once, Sep 15, 2009 IP
  4. Mastermaniac

    Mastermaniac Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Actually, I didn't get what exactly you want!

    You want the TAG to be in front of the Typed Text or before?
     
    Mastermaniac, Sep 18, 2009 IP
  5. die4once

    die4once Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    In front of the typed text, but if I add another tag I want it to be after the first tag.
    e.g
    "(typedtext)"

    "(First tag added)(typedtext)"

    "(First tag added)(second tag added)(typedtext)"

    Get it?
     
    die4once, Sep 19, 2009 IP