javascript - ToLowerCase if statement not working? -



javascript - ToLowerCase if statement not working? -

ok got of work other tolowercase. not work not split if case sensitive. using drop downwards box select delimiter.

js code has been posted help guys point out issue. double checked think needs new pair of eyes.

window.onload = function() { document.getelementbyid("change").onclick = function () { var paragraph = document.getelementbyid('box').value; var x = document.getelementbyid("changecase"); var getinfo = document.getelementbyid('parawrite'); var lowercase = " "; var lowercase2 = " "; var splitat = " "; var options = document.getelementbyid("split").value; alert("above loop"); if (x.checked === true) { lowercase = paragraph.tolowercase(); } else { lowercase = paragraph; } (var = 0; < document.form1.split.options.length; i++) { if (document.form1.split.options[i].selected === true) { splitat = paragraph.split(options); alert("splitat[" + + "]=" + splitat[i]); } } console.log(document.form1.split.options); document.write(splitat +" " +splitat.length); }

html code

<!doctype html> <html> <head> <meta charset="utf-8"> <title>paragraph</title> <link rel="stylesheet" href="normalize.css"> <link rel="stylesheet" href="textbox.css"> </head> <body> <h1>please come in text</h1> <form name="form1" id="form1"> <textarea type="text" id="box" value=""/></textarea> <label for="write">case sensitive checkbox</label> <input type='checkbox' name='write' id='changecase' value='check'/><br> <input type='button' value="count" id="change"/> <select name="split" id="split"> <option value="like">like</option> <option value="monkey">monkey</option> <option value="i">i</option> <option value=".">.</option> <option value=",">,</option> <option value="?">?</option> <option value=" ">[space]</option> </select> </form> <div id="parawrite"> </div> <script type="text/javascript" src="die.js"></script> </body> </html>

some comments:

> <!doctype html>

the string "doctype" must capitals have desired effect:

<!doctype html> > <form name="form1" id="form1">

if form has id, doesn't need name. can access form using forms collection (as have in 1 place):

var theform = document.forms.form1;

and access form controls named properties of form.

> <textarea type="text" id="box" value=""/></textarea>

textarea elements don't have type or value attribute, value content. can't utilize shortag syntax element must have closing tag, , don't utilize them elements not content if doctype html. also, form controls must have name successful. if have name , in form, don't need id:

<textarea type="text" name="box" value=""></textarea>

where have:

> <input type='checkbox' name='write' id='changecase' value='check'>

it not thought have form command different values name , id attributes. improve utilize name (and don't utilize xml syntax in html document):

<input type='checkbox' name='write' value='check'>

also:

> document.write(splitat +" " +splitat.length);

that erase entire document (including head , script content) , replace argument document.write. want that?

there many other issues code, perhaps should want do, might more help.

edit

working code:

<script> window.onload = function() { var form = document.forms.form1; form.change.onclick = function () { var paragraph = form.box.value; var getinfo = document.getelementbyid('parawrite'); var splitat = form.split.value; if (form.write.checked) { paragraph = paragraph.tolowercase(); } getinfo.innerhtml = paragraph.split(splitat) + '<br>' + paragraph.split(splitat).length; } } </script> <form name="form1"> <textarea name="box"></textarea> <label for="write">make lower case</label> <input type='checkbox' name='write' id="write" value='check'><br> <input type='button' value="count" name="change"> <select name="split"> <option value="like">like</option> <option value="monkey">monkey</option> <option value="i">i</option> <option value=".">.</option> <option value=",">,</option> <option value="?">?</option> <option value=" ">[space]</option> </select> </form> <div id="parawrite"></div>

javascript html5

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -