Help With Javascript by marvzkiddx(m): 7:32pm On May 29, 2019 |
Okay guys... I seriously need help with this... I'm working on a site with a chat feature... I have a textarea section and a button that sends the value of the textarea Button code below <button id="smiley" onclick="javascript:return clickTosendmessage(\''+chatboxtitle+'\',\''+toid+'\',\''+img+'\');" class="btn-icon icon-send fa fa-paperclip-o font-24 send-container contained"></button>
The following is a button that when clicked sends the input value in textarea.. My javascript code for the function function clickTosendMessage(chatboxtitle,toid,img) {
message = $(".chatboxtextarea".val();
message = message.replace(/^\s+|\s+$/g,""
$(".chatboxtextarea".val(''); $(".chatboxtextarea".focus(); $(".input-placeholder".css({'visibility':'visible'}); $(".chatboxtextarea".css('height','20px'); if (message != '') {
$.post(siteurl+"chat.php?action=sendchat", {to: chatboxtitle, toid: toid, message: message} , function(data){
message = message.replace(/</g,"<".replace(/>/g,">".replace(/\"/g,""" message = message.replace(/\n/g, "<br />" var $con = message; var $words = $con.split(' '); for (i in $words) { if ($words[i].indexOf('http://') == 0 || $words[i].indexOf('https://') == 0) { $words[i] = '<a href="' + $words[i] + '">' + $words[i] + '</a>'; } else if ($words[i].indexOf('www') == 0 ) { $words[i] = '<a href="' + $words[i] + '">' + $words[i] + '</a>'; } } message = $words.join(' '); message = emojione.shortnameToImage(message); // Set imotions
$("#chatbox_"+chatboxtitle).append('<div class="col-xs-12 p-b-10 odd">' + '<div class="chat-image profile-picture max-profile-picture">' + '<img alt="'+username+'" src="'+siteurls+''+img+'">' + '</div>' + '<div class="chat-body">' + '<div class="chat-text">' + '<h4>'+username+'</h4>' + '<p>'+message+'</p>' + '<b>Just Now</b><span class="msg-status msg-'+chatboxtitle+'"><i class="fa fa-check"></i></span>' + '</div>' + '</div>' + '</div>');
$(".target-emoji".css({'display':'none'}); $('.hmu-filler').css({'height':0+'px'});
msgid = data; /*clearTimeout(chkSeenInterval); chkSeenInterval = setTimeout('checkMsgSeen(msgid,chatboxtitle);',3000);*/ scrollDown(); }); chatfrindList(); } chatHeartbeatTime = minChatHeartbeat; chatHeartbeatCount = 1;
var adjustedHeight = $(".chatboxtextarea".clientHeight; var maxHeight = 40;
if (maxHeight > adjustedHeight) { adjustedHeight = Math.max($(".chatboxtextarea".scrollHeight, adjustedHeight); if (maxHeight) adjustedHeight = Math.min(maxHeight, adjustedHeight); if (adjustedHeight > $(".chatboxtextarea".clientHeight) $($(".chatboxtextarea").css('height',adjustedHeight+8 +'px'); } else { $($(".chatboxtextarea").css('overflow','auto'); } return false; }
What i want to actually do is to create another button with another function.. On click of the button, i want it to send a message without inputting it in the textarea... Once the button is clicked,the message sends... Any way around this.?? |
Re: Help With Javascript by stanliwise(m): 9:35pm On May 29, 2019 |
marvzkiddx: Okay guys... I seriously need help with this...
I'm working on a site with a chat feature...
I have a textarea section and a button that sends the value of the textarea
Button code below
<button id="smiley" onclick="javascript:return clickTosendmessage(\''+chatboxtitle+'\',\''+toid+'\',\''+img+'\');" class="btn-icon icon-send fa fa-paperclip-o font-24 send-container contained"></button>
The following is a button that when clicked sends the input value in textarea..
My javascript code for the function
function clickTosendMessage(chatboxtitle,toid,img) {
message = $(".chatboxtextarea".val();
message = message.replace(/^\s+|\s+$/g,""
$(".chatboxtextarea".val(''); $(".chatboxtextarea".focus(); $(".input-placeholder".css({'visibility':'visible'}); $(".chatboxtextarea".css('height','20px'); if (message != '') {
$.post(siteurl+"chat.php?action=sendchat", {to: chatboxtitle, toid: toid, message: message} , function(data){
message = message.replace(/</g,"<".replace(/>/g,">".replace(/\"/g,""" message = message.replace(/\n/g, "<br />" var $con = message; var $words = $con.split(' '); for (i in $words) { if ($words[i].indexOf('http://') == 0 || $words[i].indexOf('https://') == 0) { $words[i] = '<a href="' + $words[i] + '">' + $words[i] + '</a>'; } else if ($words[i].indexOf('www') == 0 ) { $words[i] = '<a href="' + $words[i] + '">' + $words[i] + '</a>'; } } message = $words.join(' '); message = emojione.shortnameToImage(message); // Set imotions
$("#chatbox_"+chatboxtitle).append('<div class="col-xs-12 p-b-10 odd">' + '<div class="chat-image profile-picture max-profile-picture">' + '<img alt="'+username+'" src="'+siteurls+''+img+'">' + '</div>' + '<div class="chat-body">' + '<div class="chat-text">' + '<h4>'+username+'</h4>' + '<p>'+message+'</p>' + '<b>Just Now</b><span class="msg-status msg-'+chatboxtitle+'"><i class="fa fa-check"></i></span>' + '</div>' + '</div>' + '</div>');
$(".target-emoji".css({'display':'none'}); $('.hmu-filler').css({'height':0+'px'});
msgid = data; /*clearTimeout(chkSeenInterval); chkSeenInterval = setTimeout('checkMsgSeen(msgid,chatboxtitle);',3000);*/ scrollDown(); }); chatfrindList(); } chatHeartbeatTime = minChatHeartbeat; chatHeartbeatCount = 1;
var adjustedHeight = $(".chatboxtextarea".clientHeight; var maxHeight = 40;
if (maxHeight > adjustedHeight) { adjustedHeight = Math.max($(".chatboxtextarea".scrollHeight, adjustedHeight); if (maxHeight) adjustedHeight = Math.min(maxHeight, adjustedHeight); if (adjustedHeight > $(".chatboxtextarea".clientHeight) $($(".chatboxtextarea").css('height',adjustedHeight+8 +'px'); } else { $($(".chatboxtextarea").css('overflow','auto'); } return false; }
What i want to actually do is to create another button with another function..
On click of the button, i want it to send a message without inputting it in the textarea...
Once the button is clicked,the message sends...
Any way around this.?? always wrap your code using the code tag. |
Re: Help With Javascript by stanliwise(m): 9:38pm On May 29, 2019 |
marvzkiddx: Okay guys... I seriously need help with this...
I'm working on a site with a chat feature...
I have a textarea section and a button that sends the value of the textarea
Button code below
<button id="smiley" onclick="javascript:return clickTosendmessage(\''+chatboxtitle+'\',\''+toid+'\',\''+img+'\');" class="btn-icon icon-send fa fa-paperclip-o font-24 send-container contained"></button>
The following is a button that when clicked sends the input value in textarea..
My javascript code for the function
function clickTosendMessage(chatboxtitle,toid,img) {
message = $(".chatboxtextarea".val();
message = message.replace(/^\s+|\s+$/g,""
$(".chatboxtextarea".val(''); $(".chatboxtextarea".focus(); $(".input-placeholder".css({'visibility':'visible'}); $(".chatboxtextarea".css('height','20px'); if (message != '') {
$.post(siteurl+"chat.php?action=sendchat", {to: chatboxtitle, toid: toid, message: message} , function(data){
message = message.replace(/</g,"<".replace(/>/g,">".replace(/\"/g,""" message = message.replace(/\n/g, "<br />" var $con = message; var $words = $con.split(' '); for (i in $words) { if ($words[i].indexOf('http://') == 0 || $words[i].indexOf('https://') == 0) { $words[i] = '<a href="' + $words[i] + '">' + $words[i] + '</a>'; } else if ($words[i].indexOf('www') == 0 ) { $words[i] = '<a href="' + $words[i] + '">' + $words[i] + '</a>'; } } message = $words.join(' '); message = emojione.shortnameToImage(message); // Set imotions
$("#chatbox_"+chatboxtitle).append('<div class="col-xs-12 p-b-10 odd">' + '<div class="chat-image profile-picture max-profile-picture">' + '<img alt="'+username+'" src="'+siteurls+''+img+'">' + '</div>' + '<div class="chat-body">' + '<div class="chat-text">' + '<h4>'+username+'</h4>' + '<p>'+message+'</p>' + '<b>Just Now</b><span class="msg-status msg-'+chatboxtitle+'"><i class="fa fa-check"></i></span>' + '</div>' + '</div>' + '</div>');
$(".target-emoji".css({'display':'none'}); $('.hmu-filler').css({'height':0+'px'});
msgid = data; /*clearTimeout(chkSeenInterval); chkSeenInterval = setTimeout('checkMsgSeen(msgid,chatboxtitle);',3000);*/ scrollDown(); }); chatfrindList(); } chatHeartbeatTime = minChatHeartbeat; chatHeartbeatCount = 1;
var adjustedHeight = $(".chatboxtextarea".clientHeight; var maxHeight = 40;
if (maxHeight > adjustedHeight) { adjustedHeight = Math.max($(".chatboxtextarea".scrollHeight, adjustedHeight); if (maxHeight) adjustedHeight = Math.min(maxHeight, adjustedHeight); if (adjustedHeight > $(".chatboxtextarea".clientHeight) $($(".chatboxtextarea").css('height',adjustedHeight+8 +'px'); } else { $($(".chatboxtextarea").css('overflow','auto'); } return false; }
What i want to actually do is to create another button with another function..
On click of the button, i want it to send a message without inputting it in the textarea...
Once the button is clicked,the message sends...
Any way around this.?? There is something I am confused about. you have a button to send message, and you need another button to send message that has not bee inputed into the textarea. what kinda message are you sending? are you trying to send a signal message? if yes store in a variable and send or store in a hidden field and send. else you may need to clarify your question. |
Re: Help With Javascript by marvzkiddx(m): 10:00pm On May 29, 2019 |
stanliwise: There is something I am confused about. you have a button to send message, and you need another button to send message that has not bee inputed into the textarea.
what kinda message are you sending? are you trying to send a signal message? if yes store in a variable and send or store in a hidden field and send. else you may need to clarify your question. The second button is a thumbs up icon... On a norms,if you type :thumbup: inside the input box... The result is a thumbs up icon.... But instead of inputting it in the text area... I want it to jus send straight on click.... Do you get? |
Re: Help With Javascript by stanliwise(m): 10:08pm On May 29, 2019 |
marvzkiddx:
The second button is a thumbs up icon...
On a norms,if you type :thumbup: inside the input box... The result is a thumbs up icon.... But instead of inputting it in the text area... I want it to jus send straight on click....
Do you get? you mean if the thumb up icon is clicked. you want to send it straight to the server? if yes, then just send direct. or like I said create a hidden input field, place your data and send it. |
Re: Help With Javascript by marvzkiddx(m): 10:10pm On May 29, 2019 |
stanliwise: you mean if the thumb up icon is clicked. you want to send it straight to the server?
if yes, then just send direct. or like I said create a hidden input field, place your data and send it. How ����� Please ur digits... Let me chat you up on whatsapp |
Re: Help With Javascript by stanliwise(m): 10:12pm On May 29, 2019 |
marvzkiddx:
How�����
Please ur digits... Let me chat you up on whatsapp ------------------ |