Javascript and XHTML forms - grrrr

Busy's picture

He has: 6,151 posts

Joined: May 2001

Can anyone help me redo a section of code please.

the code is:

var i = 0
var result1=document.form1.answer1.selectedIndex
var result2=document.form2.answer2.selectedIndex
var result3=document.form3.answer3.selectedIndex
var result4=document.form4.answer4.selectedIndex
var result5=document.form5.answer5.selectedIndex

which just checks to see if the form is filled in or not, but the problem is it wont work in XHTML. XHTML you have to have selected="selected" in the option tags, where as HTML you only need selected

Busy's picture

He has: 6,151 posts

Joined: May 2001

Ok don't worry, I goofed,

I was lazy and did a search and replace on the word selected (there were 5 in the form tags) to replace with selected="selected" and it changed the ones in the code above - no wonder it wouldn't work lol

I'll leave this post here so you can all laugh at me Laughing out loud

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.