Is there a function in Javascript that is the same as VBScript’s instr? Yes! It’s string.indexOf
For info on how to use it, check out DevGuru’s page on IndexOf
by Tom
Is there a function in Javascript that is the same as VBScript’s instr? Yes! It’s string.indexOf
For info on how to use it, check out DevGuru’s page on IndexOf
by Tom 3 Comments
There is a great article and javascript on CodeProject.com. The code was originally written by BrainError.
I had to add support for labels, however. If you had a label like this:
<label for="CheckBoxID"></label>
it wouldn’t update the image if you clicked it. I added the following to the js file:
In function replaceChecks, I added one line: inputs[i].onclick = new Function(‘imgChange(‘+i+’)’);
Here’s the relevant section of code:
//set image
if(!inputs[i].disabled) {
img.onclick = new Function('checkChange('+i+')');
inputs[i].onclick = new Function('imgChange('+i+')');
}
I also had to add a separate function here:
//change the image if the checkbox is changed.
function imgChange(i) {
if(inputs[i].checked) {
document.getElementById('checkImage'+i).src=imgCheckboxTrue;
} else {
document.getElementById('checkImage'+i).src=imgCheckboxFalse;
}
}
by Tom
I did an inventory of the existing javascript auto-complete controls. Here it is: