0

Disable Drop Down List Options

    <script type="text/javascript">
        function EnableControl(Enable) {
            if (Enable) {
 
                var op = document.getElementsByClassName("LocalDestinationDropDownListITEM")
                for (var j = 0; j < op.length; j++) {
                    var ob = op[j].getElementsByTagName("option");
                    for (var i = 0; i < ob.length; i++) {
                        var dnr = op[j][i].text.toLowerCase().indexOf("**") + 1
                        ? op[j][i].disabled = false
                        : op[j][i].disabled = false;
                    }
                }
            }
            else {
                var op = document.getElementsByClassName("LocalDestinationDropDownListITEM")
                for (var j = 0; j < op.length; j++) {
                    var ob = op[j].getElementsByTagName("option");
                    for (var i = 0; i < ob.length; i++) {
                        var dnr = op[j][i].text.toLowerCase().indexOf("**") + 1
                        ? op[j][i].disabled = true
                        : op[j][i].disabled = false;
                    }
                }
            }
        }
    </script>
Written by Jamie in: Code | Tags: ,
0

Excel Hide Cell Contents

Select the cells who’s contents to hide

Right Click and select Format Cells / Press Ctrl + 1

In the Category box select “Custom”

Type box enter ‘;;;’ (three semicolons).

Click OK

The cells will appear blank on the worksheet, but a value appears in the formula bar when you click one of the cells.

Written by Jamie in: Uncategorised | Tags:
0

Conditional hide of Drop Down Lists and options

<script type="text/javascript">
var dlarr = new Array(0);
 
function restore() {
	var obj=dl
 
	for (i=0;dlarr.length > i; i++) {
		str = dlarr[i].split("-");
		obj.options[i] = new Option(str[1], str[0]);
	}
}
 
function hidevals() {
	restore()
	var optionCounter;
	var i=0;
	var arr = new Array(0);
 
	for (optionCounter = 0; optionCounter < dl.length; optionCounter++) {
		var objval = dl.options[optionCounter].value;
		var gp2 = document.getElementById("Group2").value;
		var gp3 = document.getElementById("Group3").value;
		var gp4 = document.getElementById("Group4").value;
 
		if (objval == gp2) {
		arr.push(optionCounter)
		}
		if (objval == gp3) {
		arr.push(optionCounter)
		}
		if (objval == gp4) {
		arr.push(optionCounter)
		}
	}
 
	for (i = arr.length- 1; i>=0; i--) {
		dl.remove(arr[i]);
	}
}
 
function group7() {
	var group6 = document.getElementById("Group6");
 
	if (group6.options[group6.selectedIndex].value != "ALT"){
		document.getElementById("Group7Div").style.display = "none";
	}
	else{
   	   document.getElementById("Group7Div").style.display = "table-row";
	}
}
</script>
<table>
<tr><td>Group 1</td><td>
<SELECT id="Group1" NAME="Group1" style="width:350px" >
<option value="0">Select A Group 1 Subject</option>
<option value="62034">Group 1: English </option>
</SELECT></td></tr>
 
<tr><td>Group 2</td><td>
<SELECT id="Group2" NAME="Group2" style="width:350px" onchange="hidevals();" >
<option value="0">Select A Group 2 Subject</option>
<option value="62045">Group 2: Ab Initio (beginners) Languages </option>
<option value="62002">Group 2: French</option>
<option value="63023">Group 2: German </option>
<option value="62047">Group 2: Spanish </option>
</SELECT></td></tr>
 
<tr><td>Group 3</td><td>
<SELECT id="Group3" NAME="Group3" style="width:350px" onchange="hidevals();" >
<option value="0">Select A Group 3 Subject</option>
<option value="62031">Group 3: Geography</option>
<option value="62003">Group 3: History </option>
<option value="62048">Group 3: Psychology </option>
</SELECT></td></tr>
 
<tr><td>Group 4</td><td>
<SELECT id="Group4" NAME="Group4" style="width:350px" onchange="hidevals();" >
<option value="0">Select A Group 4 Subject</option>
<option value="61990">Group 4: Biology </option>
<option value="62014">Group 4: Chemistry </option>
<option value="62020">Group 4: Physics </option>
</SELECT></td></tr>
 
<tr><td>Group 5</td><td>
<SELECT id="Group5" NAME="Group5" style="width:350px" >
<option value="0">Select A Group 5 Subject</option>
<option value="62042">Group 5: Mathematics </option>
</SELECT></td></tr>
 
<tr><td>Group 6</td><td>
<SELECT id="Group6" NAME="Group6" style="width:350px" onchange="group7();" >	
<option value="0">Select A Group 6 Subject</option>
<option value="61992">Group 6: Film Studies </option>
<option value="61955">Group 6: Visual Arts (Higher/Standard)</option>
<option value="ALT">Group 6: Second Subject from Group 2, 3 or 4</option>
</SELECT></td></tr>
 
<tr id="Group7Div" ><td>Alternative Subject</td><td>
<SELECT id="Group7" NAME="Group7" style="width:350px" >
<option value="00">Select An Additional Subject</option>
<option value="62045">Group 2: Ab Initio (beginners) Languages </option>
<option value="62002">Group 2: French</option>
<option value="63023">Group 2: German </option>
<option value="62047">Group 2: Spanish </option>
<option value="62031">Group 3: Geography</option>
<option value="62003">Group 3: History </option>
<option value="62048">Group 3: Psychology </option>
<option value="61990">Group 4: Biology </option>
<option value="62014">Group 4: Chemistry </option>
<option value="62020">Group 4: Physics </option>
</SELECT></td></tr>
</table>
<script type="text/javascript">
var dl = document.getElementById("Group7");
for (optionCounter= 0;optionCounter<dl.length; optionCounter++) {
	dlarr.push(dl.options[optionCounter].value+"-"+dl.options[optionCounter].text);
	}
hidevals();
group7();
</script>
Written by Jamie in: Code | Tags: ,
0

Javascript Form Auto Submit Timer

<form id="examination_form" action="process.aspx"  method="POST">
...
   <input class="form-control btn btn-success" type="submit" value="Finish Test" />
</form>
function timeup() {
    $("#examination_form").unbind().submit();
}
$(document).ready(function () {
    var duration = 15
    $('#countDownTimer').countdown({
        until: '+' + duration + 'M',
        format: 'MS',
        onExpiry: timeup
});
$("#examination_form").submit(function () {
        var count = $('.input-sm').filter(function () {
            return !$(this).val();
        }).length;
 
        if (count > 0) {
            alert("You have left " + count + " questions unanswered\n\n");
            return false;
        }
    });
});
Written by Jamie in: Code | Tags: , , ,