Javascript Issue with place text into text area correctly -


well edited tht looks better thomas w example. altered seems working flawlessly. , thomas ive learned , understand new way wont doing other way again. :) gonna change code in clearbox(form) too.

thanks

<html> <head>  <script language="javascript"> window.onload = function(){         windows1.style.fontweight = "bold";         windows1.style.fontsize = "12pt";         changetabs(1)         } var split_text; var urls_1; var numbercount=0; var totals; var check_time; var wait = 0; var itemcounter = 0; var tabs=1; var tabspicked=1;      function addto_boxes(form) {         split_text = document.getelementbyid("text_to_split").value;         urls_1 = split_text.split(" ", 100000);         totals = urls_1.length-1;         var boxnum = 1;         var x=0;         while (x <= totals -1 ) {             var box = document.getelementbyid( "input_box"+boxnum);             box.value = box.value + urls_1[x] + " ";             boxnum += 1;             if (boxnum > tabspicked) boxnum = 1;             x++;             clearbox(this.form)          }     }       function clearbox(form) {     document.getelementbyid("text_to_split").value = "";     var input_box = document.getelementbyid("input_box1").value;     var input_box_2 = document.getelementbyid("input_box2").value;     var input_box_3 = document.getelementbyid("input_box3").value;     var input_box_4 = document.getelementbyid("input_box4").value;     var input_box_5 = document.getelementbyid("input_box5").value;     var input_box_6 = document.getelementbyid("input_box6").value;     var input_box_7 = document.getelementbyid("input_box7").value;     var input_box_8 = document.getelementbyid("input_box8").value;     var input_box_9 = document.getelementbyid("input_box9").value;     var input_box_10 = document.getelementbyid("input_box10").value;     urls = input_box.split(" ", 100000);     urls2 = input_box_2.split(" ", 100000);     urls3 = input_box_3.split(" ", 100000);     urls4 = input_box_4.split(" ", 100000);     urls5 = input_box_5.split(" ", 100000);     urls6 = input_box_6.split(" ", 100000);     urls7 = input_box_7.split(" ", 100000);     urls8 = input_box_8.split(" ", 100000);     urls9 = input_box_9.split(" ", 100000);     urls10 = input_box_10.split(" ", 100000);     document.getelementbyid("box1").innerhtml = urls.length-1;     document.getelementbyid("box2").innerhtml = urls2.length-1;     document.getelementbyid("box3").innerhtml = urls3.length-1;     document.getelementbyid("box4").innerhtml = urls4.length-1;     document.getelementbyid("box5").innerhtml = urls5.length-1;     document.getelementbyid("box6").innerhtml = urls6.length-1;     document.getelementbyid("box7").innerhtml = urls7.length-1;     document.getelementbyid("box8").innerhtml = urls8.length-1;     document.getelementbyid("box9").innerhtml = urls9.length-1;     document.getelementbyid("box10").innerhtml = urls10.length-1;     document.getelementbyid("displaytotal").innerhtml = urls.length-1 + urls2.length-1 + urls3.length-1 + urls4.length-1 + urls5.length-1 + urls6.length-1 + urls7.length-1 + urls8.length-1 + urls9.length-1 + urls10.length-1;     }      function bold_selected_tab(tab_to_bold) {         document.getelementbyid("windows1").style.fontsize = "10pt";         document.getelementbyid("windows2").style.fontsize = "10pt";         document.getelementbyid("windows3").style.fontsize = "10pt";         document.getelementbyid("windows4").style.fontsize = "10pt";         document.getelementbyid("windows5").style.fontsize = "10pt";         document.getelementbyid("windows6").style.fontsize = "10pt";         document.getelementbyid("windows7").style.fontsize = "10pt";         document.getelementbyid("windows8").style.fontsize = "10pt";         document.getelementbyid("windows9").style.fontsize = "10pt";         document.getelementbyid("windows10").style.fontsize = "10pt";          document.getelementbyid("windows1").style.fontweight = "normal";         document.getelementbyid("windows2").style.fontweight = "normal";         document.getelementbyid("windows3").style.fontweight = "normal";         document.getelementbyid("windows4").style.fontweight = "normal";         document.getelementbyid("windows5").style.fontweight = "normal";         document.getelementbyid("windows6").style.fontweight = "normal";         document.getelementbyid("windows7").style.fontweight = "normal";         document.getelementbyid("windows8").style.fontweight = "normal";         document.getelementbyid("windows9").style.fontweight = "normal";         document.getelementbyid("windows10").style.fontweight = "normal";         tab_to_bold.style.fontweight = "bold";         tab_to_bold.style.fontsize = "12pt";     }      function changetabs(tabs) {         document.getelementbyid("tabesselected").innerhtml = tabs;         tabspicked = tabs;     }   </script> </head> <body> select number of tab use. tabs selected <b><span style="font-size:12pt" id="tabesselected"></span><br></b> <input type="button" id="windows1" style="height: 24px; width: 72px" value="tabs: 1" onclick="changetabs(1);bold_selected_tab(windows1);" />&#160; <input type="button"id="windows2" style="height: 24px; width: 72px" value="tabs: 2" onclick="changetabs(2);bold_selected_tab(windows2);" />&#160; <input type="button"id="windows3" style="height: 24px; width: 72px" value="tabs: 3" onclick="changetabs(3);bold_selected_tab(windows3);" />&#160; <input type="button"id="windows4" style="height: 24px; width: 72px" value="tabs: 4" onclick="changetabs(4);bold_selected_tab(windows4);" />&#160; <input type="button"id="windows5" style="height: 24px; width: 72px" value="tabs: 5" onclick="changetabs(5);bold_selected_tab(windows5);" />&#160; <input type="button"id="windows6" style="height: 24px; width: 72px" value="tabs: 6" onclick="changetabs(6);bold_selected_tab(windows6);" />&#160; <input type="button"id="windows7" style="height: 24px; width: 72px" value="tabs: 7" onclick="changetabs(7);bold_selected_tab(windows7);" />&#160; <input type="button"id="windows8" style="height: 24px; width: 72px" value="tabs: 8" onclick="changetabs(8);bold_selected_tab(windows8);" />&#160; <input type="button"id="windows9" style="height: 24px; width: 72px" value="tabs: 9" onclick="changetabs(9);bold_selected_tab(windows9);" />&#160; <input type="button"id="windows10" style="height: 24px; width: 72px" value="tabs 10" onclick="changetabs(10);bold_selected_tab(windows10);" /><br><br> <input id="split" type="button" value="add boxes" onclick="addto_boxes(this.form);"/>____<input id="clearbutton" type="button" value="clear" onclick="clearbox(this.form);"/><br><br> paste urls box , click add boxes<br> <textarea name="texttosplit" id="text_to_split" value="" rows="4" cols="75"></textarea><br><br><br><br>   <form name="myform" action="" method="get"> <textarea name="inputbox" id="input_box1" value="" rows="2" cols="5"></textarea> <textarea name="inputbox2" id="input_box2" value="" rows="2" cols="5"></textarea> <textarea name="inputbox3" id="input_box3" value="" rows="2" cols="5"></textarea> <textarea name="inputbox4" id="input_box4" value="" rows="2" cols="5"></textarea> <textarea name="inputbox5" id="input_box5" value="" rows="2" cols="5"></textarea><br> <textarea name="inputbox6" id="input_box6" value="" rows="2" cols="5"></textarea> <textarea name="inputbox7" id="input_box7" value="" rows="2" cols="5"></textarea> <textarea name="inputbox8" id="input_box8" value="" rows="2" cols="5"></textarea> <textarea name="inputbox9" id="input_box9" value="" rows="2" cols="5"></textarea> <textarea name="inputbox10" id="input_box10" value="" rows="2" cols="5"></textarea><br> <input type="reset"> </form> </body> </html> 

also thomas because of example able change function bold_selected_tab() to. think im getting hang of it. if clearbox(form) function 1 below.

    function bold_selected_tab(tab_to_bold) {         var x=1;         while (x <= 10 ) {             var box = document.getelementbyid("windows"+x);             box.style.fontsize = "10pt ";             x++;         }          var x=1;         while (x <= 10 ) {             var box = document.getelementbyid("windows"+x);             box.style.fontweight = "normal";             x++;         }          tab_to_bold.style.fontweight = "bold";         tab_to_bold.style.fontsize = "12pt";     } 

when loops & arrays, mean don't repeat inner block 10 times.

var donechecking = false; (var tab = 1; tab <= 10 && ! donechecking; tab++) {     if (tabspicked >= tab) {         if (numbercount >= totals ){             numbercount = 0;             clearbox(this.form);             donechecking = true;             break;         }         if (numbercount <= totals ){             var elementid = "input_box"+tab;             var urlindex = numbercount + tab - 1;   // why?             document.getelementbyid( elementid).value = document.getelementbyid( elementid).value + urls_1[ urlindex] + " ";         }     } } 

the sooner code cleanly & properly, sooner you'll understand you're trying do. can either choose try & learn stuff, or not. you.

if you're trying distribute space-delimited input strings, amongst n textboxes, this.

var boxnum = 1; var numboxes = tabspicked;  // these boxes or tabs? i'm calling them boxes. (var url : urls_1) {     // add current box.     var box = document.getelementbyid( "input_box"+boxnum);     box.value = box.value + urls + " ";      // advance box, rotating around n boxes.     boxnum += 1;     if (boxnum > numboxes) boxnum = 1; } 

that should simple way of doing it. see how go that.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -