₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,218 members, 8,449,192 topics. Date: Tuesday, 21 July 2026 at 12:24 PM

Toggle theme

Help With Javascript - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp With Javascript (892 Views)

1 Reply (Go Down)

Help With Javascript by marvzkiddx(op):
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"wink.val();

message = message.replace(/^\s+|\s+$/g,""wink;

$(".chatboxtextarea"wink.val('');
$(".chatboxtextarea"wink.focus();
$(".input-placeholder"wink.css({'visibility':'visible'});
$(".chatboxtextarea"wink.css('height','20px');
if (message != '') {

$.post(siteurl+"chat.php?action=sendchat", {to: chatboxtitle, toid: toid, message: message} , function(data){

message = message.replace(/</g,"&lt;"wink.replace(/>/g,"&gt;"wink.replace(/\"/g,"&quot;"wink;
message = message.replace(/\n/g, "<br />"wink;
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"wink.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"wink.clientHeight;
var maxHeight = 40;

if (maxHeight > adjustedHeight) {
adjustedHeight = Math.max($(".chatboxtextarea"wink.scrollHeight, adjustedHeight);
if (maxHeight)
adjustedHeight = Math.min(maxHeight, adjustedHeight);
if (adjustedHeight > $(".chatboxtextarea"wink.clientHeight)
$($(".chatboxtextarea"wink).css('height',adjustedHeight+8 +'px');
} else {
$($(".chatboxtextarea"wink).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"wink.val();

message = message.replace(/^\s+|\s+$/g,""wink;

$(".chatboxtextarea"wink.val('');
$(".chatboxtextarea"wink.focus();
$(".input-placeholder"wink.css({'visibility':'visible'});
$(".chatboxtextarea"wink.css('height','20px');
if (message != '') {

$.post(siteurl+"chat.php?action=sendchat", {to: chatboxtitle, toid: toid, message: message} , function(data){

message = message.replace(/</g,"&lt;"wink.replace(/>/g,"&gt;"wink.replace(/\"/g,"&quot;"wink;
message = message.replace(/\n/g, "<br />"wink;
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"wink.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"wink.clientHeight;
var maxHeight = 40;

if (maxHeight > adjustedHeight) {
adjustedHeight = Math.max($(".chatboxtextarea"wink.scrollHeight, adjustedHeight);
if (maxHeight)
adjustedHeight = Math.min(maxHeight, adjustedHeight);
if (adjustedHeight > $(".chatboxtextarea"wink.clientHeight)
$($(".chatboxtextarea"wink).css('height',adjustedHeight+8 +'px');
} else {
$($(".chatboxtextarea"wink).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"wink.val();

message = message.replace(/^\s+|\s+$/g,""wink;

$(".chatboxtextarea"wink.val('');
$(".chatboxtextarea"wink.focus();
$(".input-placeholder"wink.css({'visibility':'visible'});
$(".chatboxtextarea"wink.css('height','20px');
if (message != '') {

$.post(siteurl+"chat.php?action=sendchat", {to: chatboxtitle, toid: toid, message: message} , function(data){

message = message.replace(/</g,"&lt;"wink.replace(/>/g,"&gt;"wink.replace(/\"/g,"&quot;"wink;
message = message.replace(/\n/g, "<br />"wink;
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"wink.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"wink.clientHeight;
var maxHeight = 40;

if (maxHeight > adjustedHeight) {
adjustedHeight = Math.max($(".chatboxtextarea"wink.scrollHeight, adjustedHeight);
if (maxHeight)
adjustedHeight = Math.min(maxHeight, adjustedHeight);
if (adjustedHeight > $(".chatboxtextarea"wink.clientHeight)
$($(".chatboxtextarea"wink).css('height',adjustedHeight+8 +'px');
} else {
$($(".chatboxtextarea"wink).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(op): 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(op): 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.
Howhuh�����


Please ur digits... Let me chat you up on whatsapp
Re: Help With Javascript by stanliwise(m):
marvzkiddx:
Howhuh�����


Please ur digits... Let me chat you up on whatsapp
------------------
1 Reply

July Bootcamp Training - Full Stack Web Development With Javascript (mern Stack)Tarot Website I Cooked With JavaScript,HTMLMobile Technology: Lets Build A Mobile App With Javascript234

Software Mentor NeededRecently Acquired A Domain For My Fintech Start-up, Your Suggestions PleaseCodar Advances Progress In Nigeria Through Digital Education.