Jump to content

dynamic dropdown updating textarea help


ccrevcypsys

Recommended Posts

Hello out there in php world.lol

ne ways i need help on figuring out how to make a dynamic text area.

What it needs to do is there is a select up above the text area and when someone selects something off of that drop down and they press add (or it just does it) then i need it to post in that textbox. But i am not smart enough to come up with logic that would work out. So this is what i have at the moment.

            <select name="addServ"><?php 
$query = "SELECT * FROM `serviceRequested`";
$result = mysql_query($query);
while ($service = mysql_fetch_array($result, MYSQL_ASSOC)){ ?>
		 <option value="<?php echo $service['id']; ?>"><?php echo $service['serviceName']; ?></option> 
		 <?php } ?></select> <a href='<?php echo "serviceOrder.php?p=so&"; ?>'>Add Item</a>
            <textarea name="servicerequested" disabled="disabled" class="textArea" cols="80" rows="10">
            
            </textarea>

Link to comment
Share on other sites

give your select box and textarea unique ids

 

add a load event to the window that will call a function to listen to a change in the select box

 

window.onload = function(){

var sel_box = document.getElemetById('select_box_id');

var tex_are = document.getElemetById('text_area_id');

 

sel_box.onchange = function(){

tex_are.value += 'whaver you want to add';

}

};

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.