Monday, 15 September 2014

if then statement javascript -



if then statement javascript -

i tried "if/then" statement in javascript "then" command beingness ignored. ideas on why?

specifically want form validated 2 text boxes not blank , 1 time validated want div id = section2 appear.

function checkanswers() { var fdet = document.wastheform; if (fdet.question_type[0].checked) { var elements = new array("name","address"); var elements_name = new array("name", "address"); (var = 0; < elements.length; i++) { if ($("#" + elements[i]).val() == "") { err = "please come in " + elements_name[i] + ""; alert(err); homecoming false; } } $("#section2").show(); }

i'm assuming "then" showing of div. in case this:

function checkanswers() { var fdet = document.wastheform; if (fdet.question_type[0].checked) { if(withoutvalue("#name")) { alert("please come in name") } else if(withoutvalue("#address")) { alert("please come in address") } else { $("#section2").show(); } } } function withoutvalue(selector) { homecoming $(selector).val() === ""; }

is you're looking for?

javascript if-statement

No comments:

Post a Comment