Inserting Multiple Select Values In A Textbox Using Javascript

Discussion in 'PHP' started by bwj292, Feb 23, 2011.

  1. #1
    Hi guys,

    I've got a select list which is generated using php to dynamically grab the values from an xml file. I want to be able to select an option from the list, click on the "Insert" text and have the option "value" inserted into the text box next to the "Select" list. I need to be able to insert one value after another and have each separated by a "+" sign.

    What would be the best way to do this with Javascript?

    Thanks in advance.

    This is my current code:

    <select name="advertiserlist">
    <?php
    		foreach($result->advertisers->advertiser as $advertiser){
    			echo  '<option value="'.$advertiser->{'advertiser-id'}.'">'.$advertiser->{'advertiser-name'}.'</option>';
    		}
    ?>
    </select>
    <lable><a href="#">Insert Value</a> <input type="text" width="300px" /></lable>
    
    PHP:
     
    bwj292, Feb 23, 2011 IP