|
-
Apr 8th, 2002, 02:24 PM
#1
Thread Starter
Member
option button problem
I have webpage with 1 dropdownbox and 2 option buttons. The dropdownlist contains the values tot, mar, mam, om, bes, sja. If I click radio button 1 then for example the page tot1 has to be loaded in the page called mainframe.html. If I click radio button 2 and pick mar in the dropdownlist then mar2 has to be loaded. See for my code below.
My question is how to accomplish this because the code below does not work. It works well without the radio buttons but how can I make it work with the radio buttons so I can load 12 different pages (tot1, mar1, mam1, om1, bes1, sja1, tot2, mar2, mam2, om2, bes2, sja2)
<HTML>
<HEAD>
<script language="JavaScript">
function doArray() {
var arylnth = doArray.arguments.length;
for ( i = 0 ; i < arylnth ; i++ ) { this[i]=doArray.arguments[i] } }
function newpage() {
var choose = eval(document.dropdown.site.selectedIndex); if( (choose > 0) && (choose <
12) ) {
var section=new doArray( '',
'tot' + radio' + '.html',
'mar' + radio + '.html',
'mam' + radio + '.html',
'om' + radio + '.html',
'bes' + radio + '.html',
'sja' + radio + '.html');
top.mainframe.location = section[document.dropdown.site.selectedIndex];
}
}
</script>
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="dropdown" target="mainframe">
<p><select name="site" size="1" onchange="newpage();"
align="left">
<option selected>Afdeling.... </option>
<option>Tot</option>
<option>Mar</option>
<option>Mam</option>
<option>Oma</option>
<option>Bes</option>
<option>Sja</option>
</select> </p>
<P><INPUT type=radio name=radio value=1><INPUT type=radio name=radio value=2></P>
</form>
</BODY>
</HTML>
-
Apr 10th, 2002, 05:22 AM
#2
Frenzied Member
Is this any help?
Code:
<HTML>
<HEAD>
<script language="JavaScript">
function newpage() {
var f = document.frm1.site.options[document.frm1.site.selectedIndex].value
if(document.frm1.r1[0].checked){
f += '1.html'
}else if(document.frm1.r1[1].checked){
f += '2.html'
}else{
alert("Select option")
return false
}
parent.mainframe.location=f
}
</script>
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="frm1" target="mainframe">
<select name="site" size="1" onchange="newpage();"
align="left">
<option selected>Afdeling.... </option>
<option value='tot'>Tot</option>
<option value='mar'>Mar</option>
<option value='mam'>Mam</option>
<option value='oma'>Oma</option>
<option value='bes'>Bes</option>
<option value='sja'>Sja</option>
</select>
<INPUT type=radio name=r1>
<INPUT type=radio name=r1>
</form>
</BODY>
</HTML>
-
Apr 10th, 2002, 09:45 AM
#3
Thread Starter
Member
option problem reply
The code looks good but it doesn't work. Maybe you could have a look at what is wrong. I included the code you give me and the frameset file plus the two frames and also two output example files. The names are in blue. Probably there there is something wrong in the script because the other files are just plain HTML.
the part of the frame where the dropdownbox and the radiobuttons are located (buttonframe.html)
<HTML>
<HEAD>
<script language="JavaScript">
function newpage() {
var f = document.frm1.site.options[document.frm1.site.selectedIndex].value
if(document.frm1.r1[0].checked){
f += '1.html'
}else if(document.frm1.r1[1].checked){
f += '2.html'
}else{
alert("Select option")
return false
}
parent.mainframe.location=f
}
</script>
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="frm1" target="mainframe">
<select name="site" size="1" onchange="newpage();"
align="left">
<option selected>Afdeling.... </option>
<option value='tot'>Tot</option>
<option value='mar'>Mar</option>
<option value='mam'>Mam</option>
<option value='oma'>Oma</option>
<option value='bes'>Bes</option>
<option value='sja'>Sja</option>
</select>
<INPUT type=radio name=r1>
<INPUT type=radio name=r1>
</form>
</BODY>
</HTML>
this part of the frame the output has to appear (mainframe.html)(empty HTML file)
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
the framesetfile (fg.html)
<html>
<head>
<title></title>
<frameset rows="10%,90%">
<frame src="buttonframe.html">
<frame src="mainframe.html">
</frameset>
</head>
</html>
Two of the output files (tot1.html and tot2.html)
tot1.html
<html>
<head>
<title>tot1</title>
</head>
<body>
this is tot1<br>
this is tot1<br>
this is tot1<br>
this is tot1<br>
this is tot1<br>
this is tot1<br>
this is tot1<br>
</body>
</html>
tot2.html
<html>
<head>
<title>tot2</title>
</head>
<body>
this is tot2<br>
this is tot2<br>
this is tot2<br>
this is tot2<br>
this is tot2<br>
this is tot2<br>
this is tot2<br>
this is tot2<br>
this is tot2<br>
</body>
</html>
-
Apr 10th, 2002, 09:59 AM
#4
Frenzied Member
You need a name for the frame
Code:
<html>
<head>
<title></title>
<frameset rows="10%,90%">
<frame src="buttonframe.html">
<frame name='mainframe' src="mainframe.html">
</frameset>
</head>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|