I have TEXTAREA form, i want to add DROP DOWN LIST BOX beside it,like prefix in forum
Hi guys
i have comment form code (in black colour) below, user type the comment in TEXTAREA, and click the Submit button
i want to add DROP DOWN LIST BOX before it, that user can choose, and add that DROP DOWN value with the text in TEXTAREA into database, so just like prefix in forum
i already tried below code (in red), but still not working, please help guys what is the right code
That’s nothing JavaScript should do, it’s the job of the server side script that is processing the form data. You select something in the select element, hit the submit button, and the data will be stored in the database and can be retreived in any way you like.
var msgPrefix = document.comment_form.message_prefix.value; // the value is 1,2 or 3
value = "["+msgPrefix+"] "+ value; // but I do not see any variable named "value"
All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
I'm assuming OP's looking for something like this...
Code:
var msgPrefix = document.comment_form.message_prefix.value; // the value is 1,2 or 3
document.comment_form.message.value = msgPrefix+" "+ document.comment_form.message.value;
many thanks and GBU xelawo, Philip M, and VIPStephan
xelawo code is working
btw in the bottom code, it is better i am using name, like currently
<select name="message_prefix">
<option value=""></option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
or using id, like this
<select id="message_prefix">
<option value=""></option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
because i tried using any both of them are working