Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
I have TEXTAREA form, i want to add DROP DOWN LIST BOX beside it,like prefix in forum
Old 09-24-2012, 05:29 AM I have TEXTAREA form, i want to add DROP DOWN LIST BOX beside it,like prefix in forum
Skilled Talker

Posts: 90
Name: syu
Trades: 0
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




Quote:
<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>
__________________
Lets help each other
basketmen is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-24-2012, 01:06 PM Re: I have TEXTAREA form, i want to add DROP DOWN LIST BOX beside it,like prefix in f
chrishirst's Avatar
Defies a Status

Posts: 43,971
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Not going to happen with HTML.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-25-2012, 12:20 PM Re: I have TEXTAREA form, i want to add DROP DOWN LIST BOX beside it,like prefix in f
King Spam Talker

Posts: 1,092
Name: Paul W
Trades: 0
Unless I'm failing to understand something, why are you even bothering with AJAX? Just submit straight to the php.
__________________
Great music:
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
PaulW is online now
Reply With Quote
View Public Profile
 
Old 09-25-2012, 11:50 PM Re: I have TEXTAREA form, i want to add DROP DOWN LIST BOX beside it,like prefix in f
Skilled Talker

Posts: 90
Name: Farlando Diengdoh
Location: India
Trades: 0
It looks like you are using jQuery for ajax. As per my understanding you want the value from the drop box to be a prefix of the comment right?

In that case I'd put an id on the drop down
Code:
<input type="hidden" id="heu" name="heu" value="addreply" />
<input type="hidden" id="muser" name="muser" value="' . $this->muser . '" />
<input type="hidden" id="modid" name="modid" value="' . $this->douid . '" />
<input type="hidden" id="tun" name="tun" value="0" />

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

<textarea name="message" id="message" rows="4" cols="20" style="width: 70%;"></textarea>
</select>
then use the following script in getting the values

Code:
if (checkcomment.length > 0) {
var msgPrefix = ( "message_prefix" ).val(),
     message = ( "message" ).val(),
     heu = ("heu").val(),
     muser = ("muser").val(),
     modid = ("modid").val(),
     tun = ("tun").val(),

     messageSent = msgPrefix+message,
     dataString = "message=" + messageSent + "&heu=" + heu + "&muser=" + muser + "&modid=" + modid + "&tun=" + tun;
   $.ajax({
type: "POST",
url: "/targetfile.php",
data: dataString,
success: function(data){
if (data == "SUCCESS") {
//alert("Successful");
document.comment_form.message.value = "";
setTimeout (CommentAjax,0);
}
else {
alert("Error: "+data);
}
}
});
}
Just close the function properly...
__________________
bahlung |
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
bahlung is offline
Reply With Quote
View Public Profile Visit bahlung's homepage!
 
Reply     « Reply to I have TEXTAREA form, i want to add DROP DOWN LIST BOX beside it,like prefix in forum
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15797 seconds with 11 queries