inherit
264279
0
Feb 5, 2024 17:01:15 GMT -8
shawnatdgk
59
May 2021
shawnatdgk
|
Post by shawnatdgk on Jun 8, 2023 12:52:49 GMT -8
Trying to put together a code that adds text to the textbox using a button. Having trouble targeting the textarea in the create thread pages. Can somebody please show me some simple javascript to add text to the textarea box?
Or essentially, what is the ID for the textbox in "Create Thread" page? Thanks
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Jun 8, 2023 15:37:27 GMT -8
Trying to put together a code that adds text to the textbox using a button. Having trouble targeting the textarea in the create thread pages. Can somebody please show me some simple javascript to add text to the textarea box? Or essentially, what is the ID for the textbox in "Create Thread" page? Thanks Would something like this work for you instead? support.proboards.com/thread/637930/canned-responsesDownload link is in one of the posts.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jun 8, 2023 21:59:56 GMT -8
|
|
inherit
264279
0
Feb 5, 2024 17:01:15 GMT -8
shawnatdgk
59
May 2021
shawnatdgk
|
Post by shawnatdgk on Jun 11, 2023 20:21:47 GMT -8
Thanks guys. So I read the post with Chris and Wormo going back and forth and conquering the world like the mad geniuses that they are. But i cannot keep up! All I need to do is be able to enter text into the textarea with an onclick function. I just can't get it to happen! Ive had my head wrapped around it for 3 days now. Ive opened the editor to my browser and this is the element that it shows:
<textarea style="width: 100%; border: 0px; padding: 0px; height: 360px;" tabindex="3"></textarea> I simply try to "Edit in HTML" using my browsers editor but the text doesnt show in the textarea. I also see:
<textarea id="form_8fQT9x9E_message_input" name="message" tabindex="3" class="wysiwyg-textarea" style="display: none;"></textarea>
Not sure why the display is set to "none" or why there are even 2 textareas showing up. Looking at the id makes me think that this one is created after page load. So the textarea is made up of layers? I'm confused. Also, when I add text into this element, it does show up in the textarea, although it's not recognized when I go to submit the form, therefore sending me an error saying that I need to add a message.
I was thinking I could scope the textarea and add text to it fairly simple. What I'm trying to do seems very basic. I dont mind keeping the original create thread button.
My goal is simple. I run a small roofing business. I need somebody to start answering my business line as I am starting to get too busy handling other aspects of the business. Although, I need that person to gather specific information. Therefore, I plan to have them start a new thread every time they take a business call. On top of the page I will add some input boxes for certain questions they need to ask. When all of the questions are answered, they click a button and that button populates the textarea on the create thread page and then they click the default Create Thread button. I get it, it may be a little convoluted but it will work for the task.
so I can do all the coding, its just simple javascript. Thats where I stopped learning. Never got into the new day JSON and stuff so it's very basic in these days what I know, but enough to do the job, I think.
I just need to know how to scope the textarea in order to add text using an onclick function. Have they really made it that complicated? because back in the day I thought targeting it through the array textarea[0] would do the job.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jun 12, 2023 18:29:59 GMT -8
Scott -- I'm working on a code that will automatically insert something you upload into your post. IT works flawlessly on Quick Reply insert. But it doesn't in the WYSIWYG, I'm finding it difficult to let an outside script inject text into that. Pastuleo - Thanks! I'll try! Hopefully this will unlock some of the secrets. Pay attention to the [note] and [/note] for inserting text before and after. This includes a modifier if text was already highlighted. (by Chris)
this.addCode = function(){
var wy = $('.wysiwyg-textarea').data('wysiwyg');
if(wy.currentEditorName == "bbcode") {
var text = wy.editors.bbcode.getSelectedText();
text = "[note]"+(text || "")+"[/note]"
wy.editors.bbcode.replaceSelection(text);
}else if(wy.currentEditorName == "visual") {
var doc = wy.editors.visual.document
if (window.getSelection) {
var frag = wy.editors.visual.getRange().cloneContents();
frag.appendChild(doc.createTextNode('[/note]'));
frag.insertBefore(doc.createTextNode("[note]"), frag.firstChild);
wy.editors.visual.replaceSelection(frag);
} else if (document.selection) {
var text = wy.editors.visual.getRange().htmlText;
text = "[note]"+(text || "")+"[/note]"
wy.editors.visual.getRange().pasteHTML(text)
}
}
}
If you just want to insert something, this has brought me success in the pm wysiwyg $('.visual-editor iframe').contents().find( "body" ).html('message')
$('.subject_input input').attr('value','title');
$('.editor.bbcode-editor textarea').attr('value','message');
|
|
inherit
264279
0
Feb 5, 2024 17:01:15 GMT -8
shawnatdgk
59
May 2021
shawnatdgk
|
Post by shawnatdgk on Jun 12, 2023 19:58:54 GMT -8
Well it took a week for me to realize that my code was executing BEFORE the page load, therefore it wasn't recognizing anything. So i put it in a function and it works ....finally!
GLOBAL HEADER:
<button onclick="add()">Add Text To textarea</button> <script>
function add(){
ta = document.getElementsByTagName("textarea");
for (i=0; i < ta.length; i++){
if(pb.data("route").name == "new_thread"){
ta[i].value="Added text";
}
}
} </script>
|
|
inherit
264279
0
Feb 5, 2024 17:01:15 GMT -8
shawnatdgk
59
May 2021
shawnatdgk
|
Post by shawnatdgk on Jun 12, 2023 20:01:21 GMT -8
Pay attention to the [note] and [/note] for inserting text before and after. This includes a modifier if text was already highlighted. (by Chris)
this.addCode = function(){
var wy = $('.wysiwyg-textarea').data('wysiwyg');
if(wy.currentEditorName == "bbcode") {
var text = wy.editors.bbcode.getSelectedText();
text = "[note]"+(text || "")+"[/note]"
wy.editors.bbcode.replaceSelection(text);
}else if(wy.currentEditorName == "visual") {
var doc = wy.editors.visual.document
if (window.getSelection) {
var frag = wy.editors.visual.getRange().cloneContents();
frag.appendChild(doc.createTextNode('[/note]'));
frag.insertBefore(doc.createTextNode("[note]"), frag.firstChild);
wy.editors.visual.replaceSelection(frag);
} else if (document.selection) {
var text = wy.editors.visual.getRange().htmlText;
text = "[note]"+(text || "")+"[/note]"
wy.editors.visual.getRange().pasteHTML(text)
}
}
}
If you just want to insert something, this has brought me success in the pm wysiwyg $('.visual-editor iframe').contents().find( "body" ).html('message')
$('.subject_input input').attr('value','title');
$('.editor.bbcode-editor textarea').attr('value','message'); Sorry Scott, I didnt see this before I posted. So is what I'm doing just too simple? Because it seems to work.
|
|
inherit
264279
0
Feb 5, 2024 17:01:15 GMT -8
shawnatdgk
59
May 2021
shawnatdgk
|
Post by shawnatdgk on Jun 12, 2023 20:04:05 GMT -8
Also, I dont understand none of that coding youre doing there. Is that JSON?
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jun 12, 2023 20:20:04 GMT -8
Also, I dont understand none of that coding youre doing there. Is that JSON? That is JavaScript using the jQuery library that is built into Proboards.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Jun 13, 2023 4:52:33 GMT -8
Therefore, I plan to have them start a new thread every time they take a business call. On top of the page I will add some input boxes for certain questions they need to ask. When all of the questions are answered, they click a button and that button populates the textarea on the create thread page and then they click the default Create Thread button. I get it, it may be a little convoluted but it will work for the task. If I'm understanding this correctly, then as an alternative to Chris's posts above, there is a plugin that does that - if you do not want to code it yourself. The plugin's called Custom Post Template. The support thread for it is here: support.proboards.com/thread/437496/custom-post-templateHere's a post I did that explains the 2 "halves" of the plugin's settings: support.proboards.com/thread/616717/clan-application-form?page=1&scrollTo=6951449If you're looking to code this yourself, please disregard this post.
|
|
inherit
264279
0
Feb 5, 2024 17:01:15 GMT -8
shawnatdgk
59
May 2021
shawnatdgk
|
Post by shawnatdgk on Jun 13, 2023 19:18:23 GMT -8
Therefore, I plan to have them start a new thread every time they take a business call. On top of the page I will add some input boxes for certain questions they need to ask. When all of the questions are answered, they click a button and that button populates the textarea on the create thread page and then they click the default Create Thread button. I get it, it may be a little convoluted but it will work for the task. If I'm understanding this correctly, then as an alternative to Chris 's posts above, there is a plugin that does that - if you do not want to code it yourself. The plugin's called Custom Post Template. The support thread for it is here: support.proboards.com/thread/437496/custom-post-templateHere's a post I did that explains the 2 "halves" of the plugin's settings: support.proboards.com/thread/616717/clan-application-form?page=1&scrollTo=6951449If you're looking to code this yourself, please disregard this post. so what had happened was ....... lol I had Custom Post Template plugged in. I had my posting page just as I wanted it. But then I saw that nothing was happening on mobile. I read some more posts here on Support and saw that plugins don't work with mobile version. So i dumped Custom Post Template and started on this venture lead by the first post of this thread lol. Yesterday I learned that Proboards actually granted the ability to turn off mobile version since 2018. So now I'm back to the Custom Post Template plugin where I started lol.
|
|