javascript: opions "undefined"

A

arno

Hello,

I'd like to read the content of optionbuttons ("radio") but I always get
"undefined". What's going wrong here?

I enclosed a sample (reduced to the minimum).

Thank you

arno

my testpage:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function yepp() {
alert("hello!")
alert(document.kk.nn.value)
alert(document.kk.nn.value)
}
//-->
</script>
</head>
<body>
<form name="kk" method="POST" onSubmit="return yepp()">
<input type="radio" name="nn" value="xx" checked>xx
<input type="radio" name="nn" value="yy">yy
<input type="submit" value="post data" name="submit" >
</form>

</body>
</html>
 
S

Steve Easton

Change this: onSubmit="return yepp()">
to this: onSubmit="yepp()">

You're calling a function, not "returning one"


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed..................
...............................with a computer
 
A

arno

Hello Steve,
Change this: onSubmit="return yepp()">

I did not extract this correctly from my original code. However, the
solution was that I have to loop through the options like

for(i=0;i<myform.myfield.length;i++){
if(myform.myfield.checked)alert(myform.myfield.value)

Thank you for helping!

arno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top