Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,966 members, 7,806,797 topics. Date: Wednesday, 24 April 2024 at 12:38 AM

Help With Javascript - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help With Javascript (758 Views)

Tarot Website I Cooked With JavaScript,HTML / Mobile Technology: Lets Build A Mobile App With Javascript / My Semester GPA Calculator With Javascript (2) (3) (4)

(1) (Reply) (Go Down)

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"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(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
------------------

(1) (Reply)

How To Fix A Phone That Won’t Charge / Ebook App Developer Wanted / React Native Developer Is Needed

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 48
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.