Forum Moderators: open
. . . I cannot name the form (not that I don't know how, but because I am not allowed to).. . .
What is not allowing you to name the form? One would naturally make the presumption that this is some form of an external restraint, such as an instructor. Additionally, I don't think SpaceFrog's first language is English.
Based on the radio selected, I am wanting to fill a <span> tag with either a correct/incorrect message (preferably different color font).
Don't know if you can to this. You'd have to regenerate the document or write your value to another text field, one that you can set the onFocus() so that it can't be edited. For example, (framework only, not tested:)
<input type="radio" onClick="addVal(this.form,'yes');" value="yes" /> Si
<input type="radio" onClick="addVal(this.form,'no');" value="yes" /> Niet
<input type="text" name="result" value="" onFocus="blur();" />
.....
function addVal(form,val) {
form.result.value=val;
}
By referencing the form with the "this" keyword it allows you to manage it as a generic object without it being specifically named. SpaceFrog's solution would work if it's the FIRST or only form on the page (forms array index 0.)
Additionally, I'm pretty sure you could set the style of the text field so that the borders don't show and it looks like a part of the page rather than a form field.
Thanks for the replies. I can see how you may thing that by being 'not allowed' to name my form may seem like this is coming from an instructor/teacher. However, in my case maybe I should have used the word able instead of allowed. By this I mean that the way this form has been set up for me (by developers)that it uses an html tld that doesn't allow the naming of the form (does this make sense?). Anyways, that is the only reason for not being able/allowed to name the form. I apologise for finding Spacefrog's initial reply insulting, I guess when you're new and not very good at (in this case JS) and all you're looking for is an answer/help, the reponse felt like a dig at my intelligence. I appreciate the responses and advice.
Thanks!