From 72c70a64c6d10fd2393fc6e0f81b9122022e4a00 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Dec 2014 23:54:11 -0600 Subject: [PATCH] changes in js and html file --- index.html | 50 +++++++++++------------ js/index.js | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++ js/results.js | 54 +++++++++++++++++++++++++ results.html | 15 ++++++- 4 files changed, 201 insertions(+), 28 deletions(-) create mode 100644 js/index.js create mode 100644 js/results.js diff --git a/index.html b/index.html index 5fbd42f..8e0b5cb 100644 --- a/index.html +++ b/index.html @@ -32,33 +32,29 @@

The User Interface Developer Test

-
-
- Select All -
-
- - - - - - -
- -
- + + + +
+ +Select All
+Abstract
+Publication
+Inventor
+Language
+Source
+Priority

+ + +
+ + + + + + + + \ No newline at end of file diff --git a/js/index.js b/js/index.js new file mode 100644 index 0000000..7042ba0 --- /dev/null +++ b/js/index.js @@ -0,0 +1,110 @@ +"use strict" + +$(document).ready(function() { + + $('#main').change(function() { + + if ($(this).is(':checked')) { + $('input[name="fields"]:checkbox').attr('checked', true); + + } else { + + $('input[name="fields"]:checkbox').attr('checked', false); + } + }); + + +$('input[name="fields"]:checkbox').change(function() { + var chkLength = $('input[name="fields"]:checkbox').length; + var checkedLen = $('input[name="fields"]:checkbox:checked').length; + if (chkLength == checkedLen) { + $('#main').attr('checked', true); + } else { + $('#main').attr('checked', false); + } +}); + + +$('#submit').on("click",function(){ + + var abstract = document.getElementById("Abstract"); + var Publication = document.getElementById("Publication"); + var Inventor = document.getElementById("Inventor"); + var Language = document.getElementById("Language"); + var Source = document.getElementById("Source"); + var Priority = document.getElementById("Priority"); + + + if (Language.checked == true && + document.getElementById("main").checked == false && + abstract.checked == false && + Publication.checked == false && + Inventor.checked == false && + Source.checked == false && + Priority.checked == false) + { + alert("ERROR-- Please choose more items!"); + + } + + else if ( + //document.getElementById("lang").checked == true || + document.getElementById("main").checked == true || + abstract.checked == true || + Publication.checked == true || + Inventor.checked == true || + Source.checked == true || + Priority.checked == true ) + { + + alert("success"); + document.getElementById("contacts").action = "results.html"; + + } + +//----------------------------------------------------------------------------------- + var d=document; + var contacts = d.getElementById('contacts'); + + //submit event registration + + var count = 0; + var contactArray = inputsToArray(contacts.children); + var data = serializeArray(contactArray, ''); + console.log(data); + localStorage.setItem("count",data); + + + + function inputsToArray (inputs) { + var arr = []; + for (var i = 0; i < inputs.length; i++) { + if (inputs[i].checked) + arr.push(inputs[i].value); + } + return arr; + } + + + function serializeArray (array, name) { + var serialized = ''; + + for(var i = 0, j = array.length; i < j; i++) { + if(i>0) serialized += ''+"
"; + + serialized += name + '' + array[i]; + } + return serialized; + } +//-------------------------------------------------------------------------------------- + + + + + + + +}); + + +}); \ No newline at end of file diff --git a/js/results.js b/js/results.js new file mode 100644 index 0000000..7623109 --- /dev/null +++ b/js/results.js @@ -0,0 +1,54 @@ +// "use strict" + +// function getParameters(){ +// var index = document.URL.indexOf('?'); +// var params = new Array(); +// if (index != -1) { +// var pairs = document.URL.substring(index+1, document.URL.length).split('&'); +// for (var i=0; i"); +// fields = unescape(params["fields"]); +// document.write("check box selected is = " + fields + "
"); + + +// "use strict" + +// var allVals = []; +// $(function() { + +// $('#myForm .btn btn-default').click(function() { +// allVals = [] +// alert("hello button"); + +// $('#myForm :checked').each(function() { +// allVals.push($(this).val()); +// }); +// alert("Values " + allVals); + +// $.ajax({ +// type: "POST", +// url: "file:///C:/sg/web/TestMe_lite/results.html", +// data: "allVals=" + allVals, +// success: function(response){ +// $('#info').html("OK! Data [" + allVals + "] Sent with Response:" + response); +// }, +// error: function(e){ +// $('#info').html("selected Data[" + allVals +"] Not sent with Error:" + e); +// } +// }); + +// }); + + +// }); diff --git a/results.html b/results.html index dfe49cf..3b105c9 100644 --- a/results.html +++ b/results.html @@ -31,7 +31,20 @@

You made it to the results page!

  • Tastefully display the selections the user made .
  • Fix the json3 and css includes for IE7.
  • - +

    The Items Selected is

    + +
    + +

    + +
    + +
    + \ No newline at end of file