Results 1 to 2 of 2

Thread: I have TEXTAREA form, i want to add DROP DOWN LIST BOX beside it,like prefix in forum

  1. #1
    Join Date
    Apr 2007

    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

    <script language="javascript" type="text/javascript">


    $("#form_submit").click(function() {
    document.getElementById("form_submit").disabled = true;
    checkcomment = trim(document.comment_form.message.value);

    if (checkcomment.length > 0) {
    var msgPrefix = document.forms["comment_form"].elements["message_prefix"].options[document.forms["comment_form"].elements["message_prefix"].selectedIndex].value;
    value = "["+msgPrefix+"] "+value;

    else {
    alert("Please type some text");
    document.getElementById("form_submit").disabled = false;

    function comment_done() { }
    function comment_submit()
    type: "POST",
    url: "/targetfile.php",
    data: $("#comment_form").serialize(),
    success: function(data){
    if (data == "SUCCESS") {
    document.comment_form.message.value = "";
    setTimeout (CommentAjax,0);
    else {
    alert("Error: "+data);


    <form id="comment_form" name="comment_form" method="post">
    <input type="hidden" name="heu" value="addreply" />
    <input type="hidden" name="muser" value="' . $this->muser . '" />
    <input type="hidden" name="modid" value="' . $this->douid . '" />
    <input type="hidden" name="tun" value="0" />

    <select name="message_prefix">
    <option value=""></option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>

    <textarea name="message" rows="4" cols="20" style="width: 70%;"></textarea><br />

    <input type="button" id="form_submit" value="Submit" />
    ME me me

  2. #2
    Join Date
    Jul 2011
    First of all you have to implement trim function for old browsers (all new browsers have trim already implemented), it may be something like this (add it before $(document).ready):
    if (!String.prototype.trim) {
        String.prototype.trim = function() {
            return this.replace(/^\s+|\s+$/g, "");
    After this you can call trim in this way:
        var checkcomment = document.comment_form.message.value.trim();
    Also add this line above document.getElementById("form_submit").disabled = true; :
        var value = "";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center