Alert() won't execute the <input> tags you have specified.
Try wrapping the form inside a <div> tag instead with the CSS style="display:none".
Then when required, change the style to "display:block" which should 'pop-up' the tag with the contents visible.
I've been playing with the code some. Here is my Javascript with the html:
<HTML>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var myOption = false
function initValue() {
myOption = document.forms[0].pet[3].checked
}
function pet(form) {
for (var i = 0; i < form.pet.length; i++) {
if (form.pet[i].checked) {
break
}
}
alert("You chose " + form.pet[i].value + ".")
}
function pet(form) {
for (var i = 0; i < form.pet.length; i++) {
if (form.pet[i].checked) { break }
}
alert("You chose " + form.pet[i].value + ".")
}
Save the loop 'i' value in another variable as it is not recognize outside the loop.
Try:
Code:
function pet(form) {
var flag = -1;
for (var i = 0; i < form.pet.length; i++) {
if (form.pet[i].checked) { flag = i; break; }
}
if (flag < 0) { alert('Nothing checked!'); } else { alert("You chose " + form.pet[flag].value + "."); }
}
Where do you call the function "pet(form)"? Don't expect an alert if the function is never called!
And what is "fullName(this.form)" supposed to do?
When do you initialize using "initValue()"?
And why not just
<input type="radio" name="ped" value="Fish" onClick="setShemp(true)" checked>
instead of the function?
Also, "language='JavaScript'" is depricated so you should use:
<script type="text/javascript">
instead.
That worked! Thanks
I guess I need to update my code. Also, I was trying so many things, that I forgot to go back and define (or undefine).
Thnaks again.
Bookmarks