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 3 Comments
I have in the past wanted to have the cursor look like it was hovering over a link when it was not in fact over an link. As you know, when the cursor is over a link it shows up as a hand. Well, what if you want them to click something that isn’t a link – how do you communicate that it is clickable.
The answer is cursor:hand for Internet Explorer (IE) and cursor:pointer for Mozilla and Netscape (NS).
Here’s the cross browser CSS:
p.pointerhand {
cursor: pointer;
cursor: hand;
}
More information on cursor styles: http://www.quirksmode.org/css/cursor.html