"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@194.109.133.242...
mantrid wrote on 25 aug 2006 in comp.lang.javascript:
ok thanks for that it displays the value but I need that value in my
function and I dont want to have a submit button.
You will need a way to trigger your function AFTER the radio is set by the
user. do you use a timeout then?
I use one of five buttons but not in a form as submit
so i modified my
function to:
******************************
function show(ele,invele1,invele2,invele3,invele4) {
What does these ele,invele1,invele2,invele3,invele4 have to do with it?
Thats to determine which column in a table is made visible. The function is
used by each of the 5 buttons mentioned above. Hence the 5 arguments in the
function. That bit works so I'm OK with that.
>
var radios = document.getElementsByName("radtext");
for(var i = 0; i < radios.length; i++){
if(radios[i].checked) {
var checkedrad= radios[i].value);
Why the final ) ?
I copied and modified
<form name="myform"
onsubmit=
'radios = document.getElementsByName("radtext");
for(var i = 0; i < radios.length; i++)
if(radios[i].checked)
alert( radios[i].value);
from your earlier post and forgot to delete the ) from the 'alert'. In fact
that was the problem. I was working very late last night and overlooked it
when checking the code after modifying it.
heres the whole working function anyway as you are interested. (any advice
about tidying it up, (besides what you already said), appreciated)
<script type="text/javascript" language="javascript">
<!--
function show(ele,invele1,invele2,invele3,invele4) {
var radios = document.getElementsByName("radtext");
for(var i = 0; i < radios.length; i++)
if(radios[i].checked)
var checkedrad= radios[i].value;
switch (checkedrad){
case '1':
var starty=2;
var finishy=14;
break
case '2':
var starty=13;
var finishy=30;
break
case '3':
var starty=30;
var finishy=32;
break
default:
var starty=2;
var finishy=32;
}
for(var y = starty; y <= finishy; y++){
var srcElement = document.getElementById(ele+y);
var srcElement1 = document.getElementById(invele1+y);
var srcElement2 = document.getElementById(invele2+y);
var srcElement3 = document.getElementById(invele3+y);
var srcElement4 = document.getElementById(invele4+y);
srcElement1.style.display='none';
srcElement2.style.display='none';
srcElement3.style.display='none';
srcElement4.style.display='none';
if(srcElement.style.display == "block") {
srcElement.style.display= 'none';
}
else {
srcElement.style.display='block';
}
}
}
//-->
</script>
Thanks again for your help
I didnt know that in javascript use of curly brackets is optional. Ive been
using php mostly, javascript is new to me.
Ian