what i need is, if someone hits ok on a javascript input box, then their inputed text comes out normal. but if they hit cancel, their inputed text should come out blue.
heres my code:
Code:
<script type="text/javascript">
function firstName() {
var name = prompt ("Please Enter Your Name");
alert('Some Text');
document.getElementById("1").innerHTML = name;
document.getElementById("2").innerHTML = name;
document.getElementById("3").innerHTML = name;
document.getElementById("4").innerHTML = name;
document.getElementById("5").innerHTML = name;
document.getElementById("6").innerHTML = name;
document.getElementById("7").innerHTML = name;
document.getElementById("8").innerHTML = name;
document.getElementById("9").innerHTML = name;
document.getElementById("10").innerHTML = name;
document.getElementById("11").innerHTML = name;
}
</script>
im sure id use and if else statement but im not entirely sure how this can be done. any help would be appreciated, thanks.
OK, both names and ids are supposed to start with a letter. So...
HTML Code:
<script type="text/javascript">
function firstName() {
var obj = document.getElementById("D1");
var name = prompt("Please Enter Your Name");
if (comfirm(name)) {
obj.innerHTML = name;
} else {
obj.innerHTML = name;
obj.style.color = 'blue';
}
}
</script>
That of course assumes that your visitor doesn't check the disable JavaScript checkbox at the bottom of the prompt or confirm dialog so as to kill the rest of the script (assuming that they are using a browser that always offers that option in all the dialogs to make using them for testing easier).
Bookmarks