{"id":57721,"date":"2022-12-10T03:01:04","date_gmt":"2022-12-09T17:01:04","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=57721"},"modified":"2022-12-09T08:41:59","modified_gmt":"2022-12-08T22:41:59","slug":"textbox-div-contenteditable-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/textbox-div-contenteditable-primer-tutorial\/","title":{"rendered":"Textbox Div Contenteditable Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/divceditin.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Textbox Div Contenteditable Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/divceditin.jpg\" title=\"Textbox Div Contenteditable Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Textbox Div Contenteditable Primer Tutorial<\/p><\/div>\n<p>We have an idea for use for the following componentry &#8230;<\/p>\n<ol>\n<li>div <a target=_blank title='Global contenteditable attribute information from W3schools' href='https:\/\/www.w3schools.com\/tags\/att_global_contenteditable.asp'>contenteditable<\/a>=true &#8230; <font size=1>only<\/font> hosting &#8230;<\/li>\n<li>input type=text value=&#8221; <a target=_blank href='https:\/\/www.w3schools.com\/tags\/att_input_placeholder.asp#:~:text=Definition%20and%20Usage,the%20user%20enters%20a%20value.' title='HTML placeholder attribute'>placeholder<\/a>=[Some Instructive Blurb] readonly<\/li>\n<\/ol>\n<p> &#8230; initially like &#8230;<\/p>\n<p><code><br \/>\n&lt;div onblur=docss(this.innerText); data-style='border: 1px solid blue;' id=mydiv contenteditable=true onclick=\"if (this,innerText.length == 0) { this.innerHTML=''; this.focus(); this.style.border='1px solid blue';   }\"&gt;&lt;input style='border: 1px solid transparent;width:100%;' type=text placeholder='\/* CSS styling can go here via a click ... eg. background-color: yellow;  *\/' value='' readonly&gt;&lt;\/input&gt;&lt;\/div&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; and respond to a click and scrutiny of [divElement].<a target=_blank title='HTML DOM innerText attribute info from W3schools'  href='https:\/\/www.w3schools.com\/jsref\/prop_node_innertext.asp'>innerText<\/a> attribute (blank when empty or just containing that input type=text element) to decide when to bring on the contenteditable=true way to glean some content from the user.<\/p>\n<p>Then we started thinking about the elements above and any accompanying Javascript and saw that we could make an external Javascript (<a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/divceditin.js_GETME\" title=\"divceditin.js\">divceditin.js<\/a>) tool out of this &#8230;<\/p>\n<p><code><br \/>\n\/\/ divceditin.js<br \/>\n\/\/ Help out divceditin.html dynamic style definition<br \/>\n\/\/ RJM Programming - December, 2022<br \/>\n<br \/>\n var todoccwith=location.search.split('tod' + 'owith=')[1] ? decodeURIComponent(location.search.split('tod' + 'owith=')[1].split('&')[0]) : (document.head.innerHTML.split('tod' + 'owith=').length &lt;= 1) ? \"*\" : decodeURIComponent(document.head.innerHTML.split('tod' + 'owith=')[1].split('&')[0].split('\"')[0].split(\"'\")[0].split(\"#\")[0].split(\"&gt;\")[0]);<br \/>\n var afyourster=location.search.split('af' + 'ter=')[1] ? decodeURIComponent(location.search.split('af' + 'ter=')[1].split('&')[0]) : (document.head.innerHTML.split('af' + 'ter=').length &lt;= 1) ? \"\" : decodeURIComponent(document.head.innerHTML.split('af' + 'ter=')[1].split('&')[0].split('\"')[0].split(\"'\")[0].split(\"#\")[0].split(\"&gt;\")[0]);<br \/>\n var beyoursfore=location.search.split('bef' + 'ore=')[1] ? decodeURIComponent(location.search.split('bef' + 'ore=')[1].split('&')[0]) : (document.head.innerHTML.split('bef' + 'ore=').length &lt;= 1) ? \"\" : decodeURIComponent(document.head.innerHTML.split('bef' + 'ore=')[1].split('&')[0].split('\"')[0].split(\"'\")[0].split(\"#\")[0].split(\"&gt;\")[0]);<br \/>\n var blyoursurb=location.search.split('bl' + 'urb=')[1] ? decodeURIComponent(location.search.split('bl' + 'urb=')[1].split('&')[0]) : (document.head.innerHTML.split('bl' + 'urb=').length &lt;= 1) ? \"\/* CSS styling can go here via a click ... eg. border-radius: 50%;  *\/\" : decodeURIComponent(document.head.innerHTML.split('bl' + 'urb=')[1].split('&')[0].split('\"')[0].split(\"'\")[0].split(\"#\")[0].split(\"&gt;\")[0]);<br \/>\n var blyoururb=blyoursurb;<br \/>\n if (blyoursurb.indexOf(' *\/') != -1 && blyoursurb.indexOf(' eg. ') != -1) {<br \/>\n     blyoururb=blyoursurb.replace(' *\/', ' } *\/').replace(' eg. ', ' eg. ' + ('' + todoccwith) + ' { ');<br \/>\n }<br \/>\n<br \/>\n function supdocss() {<br \/>\n   docss('');<br \/>\n }<br \/>\n<br \/>\n if (typeof docss !== \"function\") {<br \/>\n function docss(txt) {<br \/>\n   var documentcbody=document.body;<br \/>\n   var sparecc='';<br \/>\n   if (afyourster.trim() != '') {<br \/>\n     if (document.getElementById(afyourster.trim())) {<br \/>\n       documentcbody=document.getElementById(afyourster.trim().replace('#',''));<br \/>\n     } else {<br \/>\n       afyourster='';<br \/>\n     }<br \/>\n   }<br \/>\n   if (beyoursfore.trim() != '') {<br \/>\n     if (document.getElementById(beyoursfore.trim())) {<br \/>\n       documentcbody=document.getElementById(beyoursfore.trim().replace('#',''));<br \/>\n     } else {<br \/>\n       beyoursfore='';<br \/>\n     }<br \/>\n   }<br \/>\n   if (todoccwith.trim() != '') {<br \/>\n     if (document.getElementById(todoccwith.trim().replace('#','')) && todoccwith.indexOf('#') == -1) {<br \/>\n       blyoururb=blyoururb.replace(' eg. ' + ('' + todoccwith) + ' { ', ' eg. #' + ('' + todoccwith) + ' { ');<br \/>\n       todoccwith=location.search.split('tod' + 'owith=')[1] ? ('#' + decodeURIComponent(location.search.split('tod' + 'owith=')[1].split('&')[0])) : (document.head.innerHTML.split('tod' + 'owith=').length &lt;= 1) ? \"*\" : ('#' + decodeURIComponent(document.head.innerHTML.split('tod' + 'owith=')[1].split('&')[0].split('\"')[0].split(\"'\")[0].split(\"#\")[0].split(\"&gt;\")[0]));<br \/>\n     }<br \/>\n   }<br \/>\n   if (!document.getElementById('dstyle') && !document.getElementById('mydiv')) {<br \/>\n     if (todoccwith.replace('*','') == '') {<br \/>\n     if (beyoursfore.trim() != '') {<br \/>\n     sparecc=documentcbody.innerHTML;<br \/>\n     documentcbody.innerHTML=\"&lt;div onblur=docss(this.innerText); data-style='border: 1px solid blue;' id=mydiv contenteditable=true onclick=\\\"if (this,innerText.length == 0) { this.innerHTML=''; this.focus(); this.style.border='1px solid blue';   }\\\"&gt;&lt;input style='border: 1px solid transparent;width:100%;' type=text placeholder='\" + blyoursurb + \"' value='' readonly&gt;&lt;\/input&gt;&lt;\/div&gt;\" + sparecc;<br \/>\n     } else {<br \/>\n     documentcbody.innerHTML+=\"&lt;div onblur=docss(this.innerText); data-style='border: 1px solid blue;' id=mydiv contenteditable=true onclick=\\\"if (this,innerText.length == 0) { this.innerHTML=''; this.focus(); this.style.border='1px solid blue';   }\\\"&gt;&lt;input style='border: 1px solid transparent;width:100%;' type=text placeholder='\" + blyoursurb + \"' value='' readonly&gt;&lt;\/input&gt;&lt;\/div&gt;\";<br \/>\n     }<br \/>\n     document.body.innerHTML+=\"&lt;div id=dstyle style=display:none;&gt;&lt;\/div&gt;\";<br \/>\n     } else {<br \/>\n     if (beyoursfore.trim() != '') {<br \/>\n     sparecc=documentcbody.innerHTML;<br \/>\n     documentcbody.innerHTML=\"&lt;div onblur=docss(this.innerText); data-style='border: 1px solid blue;' id=mydiv contenteditable=true onclick=\\\"if (this,innerText.length == 0) { this.innerHTML=''; this.focus(); this.style.border='1px solid blue';   }\\\"&gt;&lt;input style='border: 1px solid transparent;width:100%;' type=text placeholder='\" + blyoururb + \"' value='' readonly&gt;&lt;\/input&gt;&lt;\/div&gt;&lt;div id=dstyle style=display:none;&gt;&lt;\/div&gt;\" + sparecc;<br \/>\n     } else {<br \/>\n     documentcbody.innerHTML+=\"&lt;div onblur=docss(this.innerText); data-style='border: 1px solid blue;' id=mydiv contenteditable=true onclick=\\\"if (this,innerText.length == 0) { this.innerHTML=''; this.focus(); this.style.border='1px solid blue';   }\\\"&gt;&lt;input style='border: 1px solid transparent;width:100%;' type=text placeholder='\" + blyoururb + \"' value='' readonly&gt;&lt;\/input&gt;&lt;\/div&gt;&lt;div id=dstyle style=display:none;&gt;&lt;\/div&gt;\";<br \/>\n     }<br \/>\n     }<br \/>\n   } else if (!document.getElementById('mystyle')) {<br \/>\n     document.body.innerHTML+=\"&lt;div id=dstyle style=display:none;&gt;&lt;\/div&gt;\";<br \/>\n   }<br \/>\n   if (txt.trim() != '') {<br \/>\n    if (txt.trim().indexOf('{') == -1) {<br \/>\n     document.getElementById('dstyle').innerHTML+=(' &lt;style&gt; ' + todoccwith + ' { ') + txt.replace('&lt;style&gt;','').replace('&lt;\/style&gt;','') + ' } &lt;\/style&gt; ';<br \/>\n    } else {<br \/>\n     document.getElementById('dstyle').innerHTML+=' &lt;style&gt; ' + txt.replace('&lt;style&gt;','').replace('&lt;\/style&gt;','') + ' &lt;\/style&gt; ';<br \/>\n    }<br \/>\n   }<br \/>\n };<br \/>\n }<br \/>\n<br \/>\n function btaf() {<br \/>\n if (document.body.outerHTML.split('&gt;')[0].indexOf('doc' + 'ss(') == -1) {<br \/>\n  setTimeout(supdocss, 2000);<br \/>\n }<br \/>\n }<br \/>\n<br \/>\n setTimeout(btaf, 500);<br \/>\n<\/code><\/p>\n<p> &#8230; because what we can use this for is to service the content for dynamic CSS appending to a webpage to make it dynamic looking, as with our <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/divceditin.html_GETME\" title=\"divceditin.html\">divceditin.html<\/a> sample user of the external Javascript above, in a <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/divceditin.html\" title=\"Click picture\">web application<\/a>, or you using below &#8230;<\/p>\n<p><iframe src=http:\/\/www.rjmprogramming.com.au\/divceditin.html style=width:100%;height:800px;><\/iframe><\/p>\n<p><i><b>Stop Press<\/b><\/i><\/p>\n<p>Yesterday&#8217;s <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/css-gradient-creations-conic-tutorial\/' title='CSS Gradient Creations Conic Tutorial'>CSS Gradient Creations Conic Tutorial<\/a>&#8216;s integration of the day before <a target=_blank title='CSS Conic Gradient Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/css-conic-gradient-primer-tutorial'>CSS Conic Gradient Primer Tutorial<\/a>&#8216;s work was missing some of the features of that latter <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/congrad.html\">web application<\/a>, involving its textarea flexibility to add user additional dynamic CSS into the mix.  No problems any longer, as we make use of the work of today, above, integrating into <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/css-gradient-creations-conic-tutorial\/' title='CSS Gradient Creations Conic Tutorial'>CSS Gradient Creations Conic Tutorial<\/a>&#8216;s <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/gradient_creations.htm'>web application<\/a> one new line of code &#8230;<\/p>\n<p><code><br \/>\n&lt;script 'type=text\/javascript' src='\/divceditin.js?todowith=tdlook&after=tdcss&blurb=%2F*%20More%20gradient%20CSS%20styling%20can%20go%20here%20via%20a%20click%20...%20eg.%20border-radius%3A%2050%25%3B%20%20*%2F'&gt;&lt;\/script&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; to offer that possibility.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d57721' onclick='var dv=document.getElementById(\"d57721\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/placeholder\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d57721' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We have an idea for use for the following componentry &#8230; div contenteditable=true &#8230; only hosting &#8230; input type=text value=&#8221; placeholder=[Some Instructive Blurb] readonly &#8230; initially like &#8230; &lt;div onblur=docss(this.innerText); data-style=&#8217;border: 1px solid blue;&#8217; id=mydiv contenteditable=true onclick=&#8221;if (this,innerText.length == 0) &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/textbox-div-contenteditable-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[2236,112,211,2442,281,342,354,1683,1549,576,1525,2469,609,652,861,2643,997,2366,1200,1209,1212,1675,1319],"class_list":["post-57721","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-append","tag-attribute","tag-click","tag-contenteditable","tag-css","tag-div","tag-dom","tag-dynamic","tag-element","tag-html","tag-innerhtml","tag-innertext","tag-input","tag-javascript","tag-onclick","tag-placeholder","tag-programming","tag-readonly","tag-stop-press","tag-style","tag-styling","tag-textbox","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/57721"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=57721"}],"version-history":[{"count":10,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/57721\/revisions"}],"predecessor-version":[{"id":57731,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/57721\/revisions\/57731"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=57721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=57721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=57721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}