hint
.checked == true _______________________________________________ { str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee"alert(Nstr); }
_______________________________________________
for the best results to your questions: FAQ333-2924
that was good
but
running what? how can i find out if a radio button has been checked or not
in the input put onClick="itwaschecked(this)"
or something
function itwaschecked(obj) {
// whatever to the event it was clicked
}
then run whtever you want on that event
btw: window and document are their own objects
window.document is wrong
either
window.
or
document.
you can't try and access two elements
elements[0][0].checked
that's why the error comes up
_______________________________________________ { str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee"alert(Nstr); }
_______________________________________________
for the best results to your questions: FAQ333-2924
running = see if it works properly in your browser
btw window.document does work.
So how can i see if the radio button is checked?
here's an example:
var path = window.document.myform
for (i=0;i<path.elements.length;i++)
{
if (path.elements[0].checked == true)
{alert('YEEAAAAHHAAAA'))
}
copy/paste got me that's only one set of checkbox's and one form _______________________________________________ { str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee"alert(Nstr); }
_______________________________________________
for the best results to your questions: FAQ333-2924
wow, but OK I'll play
<html>
<head>
<script language="JavaScript">
function testit() {
var path = document.myform
for (x=0;x<path.elements.length;x++) {
if(path.elements[x].checked) {
alert('YEEAAAAHHAAAA')
}
}
}
</script>
</head>
<body>
<form name="myform">
<input type="radio" name="k">
<input type="radio" name="k1">
<input type="radio" name="k2">
<input type="radio" name="k3">
<input type="radio" name="k4">
<input type="radio" name="k5">
<input type="button" value="see" onClick="testit()">
</form> _______________________________________________ { str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee"alert(Nstr); }
_______________________________________________
for the best results to your questions: FAQ333-2924
remember the incrementing of the counter in a loop will take a bit more logic to test for a group of radios or checkboxs (same thign basically) _______________________________________________ { str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee"alert(Nstr); }
_______________________________________________
for the best results to your questions: FAQ333-2924
on the window document object referencing
it really isn't needed to add window.document
document is a child object of the window object but not normally referenced as such. I believe the need for that ws taken away in like NN 1 _______________________________________________ { str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee"alert(Nstr); }
_______________________________________________
for the best results to your questions: FAQ333-2924
I was aiming to not ahve to write the names manually, so i can do it in a loop using the forms and elements collections. Thanks but i already found my answer.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.