JavaScript - Ignoring Whitespace
Hi all, are there any tags i can use that will tell the parser somehow to ignore whitespace in the HTML section? The html and jave script is pasted into a custom page widget that can interpret the code, the problem is that my indentation and general coding formatting as i am writing it in my editor is also somehow being translated in the rendering - it seems mostly to be the linebreaks, in fact i would say it is only the line breaks, so the layout is appearing spread across too many lines for example, instead of neat and tight together, which is what i see in a browser. I realise this is probably the parser implementation at the application end, but can i get around this directly myself?
I cannot use xml or xslt to get around this, i can only write direct html or java into this custom widget. Similar Tutorialsin the function emailTest in this code I can't seem to get the FIRST if statement to pass even if I put 1 in the in the email.value text box. even if i change the if condition to (email.value=="1") or (email.value=="a") and make the email.value text field equal respectively, IT STILL WON'T PASS only if I do (1==1) will it work. ----some background---- I was making a javascript form checker and i needed to test if the email field was an email. First I tried using an isEmail function. Didn't work. But the funciton seemed legitimate. I tinkered for hours trying to find glitches (it's simple regular expressions... i mean how hard could I screw it up?) and then eventually made the function return true by default so that the function would do nothing more but return true. Even when the function JUST returned true. (i also tried just returning 1) it still didn't pass. Then I took the function out of the if statement all together and tried the regular expression test in the if function. that didn't work. Now I'm trying to compare the variable directly to something simple. AND IT STILL DOESN'T WORK. WHAT is going on here people? REALLY ... I mean REALLLY/!?!? I've been programming for 7 GD years of my GD life (not javascript honestly) and SIMPLE CODE SHOULDN'T FAIL THIS HARD. Code: function emailTest() { if (email.value==1) { emailErrorBox.innerHTML="Please insert a valid email"; emailSuccessBox.innerHTML=""; } if (email.value.length>0 && email.focus) { emailErrorBox.innerHTML="";emailSuccessBox.innerHTML=""; request.abort(); var url = "/unseen/checkIfEmailExist.php?email=" + email.value; request.open("GET", url, true); request.onreadystatechange = updateEmailCheck; request.send(null); } if (email.value.length===0) {emailErrorBox.innerHTML="Please insert an email";emailSuccessBox.innerHTML="";} } If you go to http://freetexthost.com/dgbgshkzkj that is my code. It's a lot. I can't just give you a portion because I think it's something on the large scope that is screwing me up. This entire thing has me furious because IT IS SIMPLE CODE THAT REFUSES TO WORK... LITERAL REFUSAL THE COMPUTER JUST SAID NO NO NO NO. I am SERIOUSLY trying to get rolling on this project but some hidden syntax of javascript is blocking me from having these functions work correctly Hi, I currently have a <p> where it changes to a textarea when a button is clicked How do I preserve the whitespace when saving that text to a database and displaying back to a <p>? Basically I have this: function semaphore(phrase) { var len = phrase.length; var str1 = ""; for (var i=0;i<len;i++) { if(phrase[i]=" ") { phrase[i] = "interval"; } var str = "images/semaphore/" + phrase[i] + ".gif"; str1 = str1 + "<img src='" + str + "'>"; } return str1; } so if phrase = i love coding forums I want all the spaces to be replaced with the text "interval" Thanks Danny Code: for(i=0;i<document.getElementsByName('checkresult_".$i."').length;++i){ if(document.getElementsByName('checkresult_".$i."')[i].checked){ thisurlext+=document.getElementsByName('checkresult_".$i."')[i].value; checkedlength++; if(i+1<document.getElementsByName('checkresult_".$i."').length){ if(document.getElementsByName('checkresult_".$i."')[i+1].checked){ thisurlext+='+'; } } } }; Let's say I check verses 1, 2, 3, 6 I want the Javascript not to ignore the + between the 3 and the 6: Code: <div id="txt_kjv0_1_1_0" style="float: left; background-color: rgb(234, 232, 200); margin: 0px; width: 178px; height: 497px; border: 1px solid rgb(122, 16, 16); padding: 5px 5px 0px; overflow-y: auto; overflow-x: hidden;"> <input id="sc0" value="kjv" type="hidden"> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_0" name="checkresult_0" onclick="" value="1" type="checkbox"><span style="font-weight: bold; margin: 2px;">1</span>In the beginning God created the heaven and the earth.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_1" name="checkresult_0" onclick="" value="2" type="checkbox"><span style="font-weight: bold; margin: 2px;">2</span>And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_2" name="checkresult_0" onclick="" value="3" type="checkbox"><span style="font-weight: bold; margin: 2px;">3</span>And God said, Let there be light: and there was light.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_3" name="checkresult_0" onclick="" value="4" type="checkbox"><span style="font-weight: bold; margin: 2px;">4</span>And God saw the light, that it was good: and God divided the light from the darkness.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_4" name="checkresult_0" onclick="" value="5" type="checkbox"><span style="font-weight: bold; margin: 2px;">5</span>And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.</p> <p id="regular[]" name="bibletext" style="float: left; text-align: left; width: 155px; display: block; padding: 0px 2px; font-size: 12px;"><input id="check0_5" name="checkresult_0" onclick="" value="6" type="checkbox"><span style="font-weight: bold; margin: 2px;">6</span>And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.</p> |