Click to See Complete Forum and Search --> : Javascript in a HTML tag.


james
02-10-2003, 03:14 AM
Hi Guys and Gals,

I'm new here so forgive me if this is a bit of an eazy question for all you web gurus. :o

Ok, the problem I have is using the result of a javascript function to determine whether a radio button should be checked.

<input type='radio' name='answer1' value='radioQ1A2' javascipt:if(check_user()=='checked')document.write('checked');/>

It seems that my javascript function just isn't getting evaluated.

Thanks for any help you can give.

AdamGundry
02-10-2003, 04:30 AM
You can't use Javascript like that, it has to be in script tags, like this:

<script type="text/javascript">
if(check_user()=='checked'){
document.write("<input type='radio' name='answer1' value='radioQ1A2' checked />");
} else {
document.write("<input type='radio' name='answer1' value='radioQ1A2' />");
}
</script>


Adam