I have TEXTAREA form,i want to add DROP DOWN LIST BOX beside

  • basketmen
  • Student
  • Student
  • basketmen
  • Posts: 68

Post 3+ Months Ago

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 yellow), but still not working, please help guys what is the right code




JAVASCRIPT Code: [ Select ]
<div>
   <script language="javascript" type="text/javascript">      
 
$(document).ready(function(){
 
   $("#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;
   comment_submit();
   }
   else {
   alert("Please type some text");
   }
   document.getElementById("form_submit").disabled = false;
   });
   
   function comment_done() {  }
   function comment_submit()
   {
      $.ajax({
         type: "POST",
         url: "/targetfile.php",
         data: $("#comment_form").serialize(),
         success: function(data){
            if (data == "SUCCESS") {
               //alert("Successful");
               document.comment_form.message.value = "";
               setTimeout (CommentAjax,0);
               }
            else {
               alert("Error: "+data);
               }
         }
      });
   }
   
});
</script>        
 
<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>                
                    </select>
     
               <textarea name="message" rows="4" cols="20" style="width: 70%;"></textarea><br />
 
                    <input type="button" id="form_submit" value="Submit" />
                </form></div>
  1. <div>
  2.    <script language="javascript" type="text/javascript">      
  3.  
  4. $(document).ready(function(){
  5.  
  6.    $("#form_submit").click(function() {
  7.    document.getElementById("form_submit").disabled = true; 
  8.    checkcomment = trim(document.comment_form.message.value);
  9.  
  10.    if (checkcomment.length > 0) {
  11.    var msgPrefix = document.forms["comment_form"].elements["message_prefix"].options[document.forms["comment_form"].elements["message_prefix"].selectedIndex].value;      
  12.           value = "["+msgPrefix+"] "+value;
  13.    comment_submit();
  14.    }
  15.    else {
  16.    alert("Please type some text");
  17.    }
  18.    document.getElementById("form_submit").disabled = false;
  19.    });
  20.    
  21.    function comment_done() {  }
  22.    function comment_submit()
  23.    {
  24.       $.ajax({
  25.          type: "POST",
  26.          url: "/targetfile.php",
  27.          data: $("#comment_form").serialize(),
  28.          success: function(data){
  29.             if (data == "SUCCESS") {
  30.                //alert("Successful");
  31.                document.comment_form.message.value = "";
  32.                setTimeout (CommentAjax,0);
  33.                }
  34.             else {
  35.                alert("Error: "+data);
  36.                }
  37.          }
  38.       });
  39.    }
  40.    
  41. });
  42. </script>        
  43.  
  44. <form id="comment_form" name="comment_form" method="post">
  45.                     <input type="hidden" name="heu" value="addreply" />
  46.                     <input type="hidden" name="muser" value="' . $this->muser . '" />
  47.                     <input type="hidden" name="modid" value="' . $this->douid . '" />
  48.                     <input type="hidden" name="tun" value="0" />
  49.  
  50.  
  51.                     <select name="message_prefix">                
  52.                         <option value=""></option>
  53.          <option value="1">One</option>
  54.                         <option value="2">Two</option>
  55.                         <option value="3">Three</option>                
  56.                     </select>
  57.      
  58.                <textarea name="message" rows="4" cols="20" style="width: 70%;"></textarea><br />
  59.  
  60.                     <input type="button" id="form_submit" value="Submit" />
  61.                 </form></div>
Moderator Remark: Fixed code styling
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1240
  • Loc: Sydney

Post 3+ Months Ago

bbcode does not work inside CODE, just for reference just split the form in order but in blocks of code to break it down.

taking a look in DW, see what i can find.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 43 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.