NooBee
06-13-2003, 09:42 AM
Hello all, I'm very new at this but I'm hoping you can help.
I'm not a programmer but I've set up a site for my cartoons.
Basically I have this Java double combo box set up for the archive section. From the first combo box, the user can select a range of strips to be viewed 1-30, 30-60 etc. From the, then propogated second list, the user can select a specific strip.
This works fine.
I've now written some code (untested) on the end of this, that calculates the 'next' strip and the 'previous' strip.
My problem is, I don't know how to insert buttons to make said functions work!
I'd like the user to be able to press either button and be zipped to the strip of their choice.
If the combo's could be updated to show the choice, that would be cool too. Please have a look over at:
The web site (http://theamoeba.ontheweb.com/)
and select the 'Archive' item in the menu at the top of the screen to see what I mean.
Many thanks in advance for anyone kind enough to help.
The code is as follows.......
<form name="doublecombo">
<p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option>Strips 1-30</option>
<option>Strips 31-60</option>
<option>Strips 61-90</option>
<option>Strips 91-120</option>
</select>
<select name="stage2" size="1">
<option value="AmoebaStrips/Strip0000.gif">Strip 1</option>
<option value="AmoebaStrips/Strip0001.gif">Strip 2</option>
<option value="AmoebaStrips/Strip0002.gif">Strip 3</option>
(etc......)
</select>
<input type="button" name="test" value="Go!"
onClick="go()">
</p>
<script>
var groups=document.doublecombo.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group=new Array()
group[0][0]=new Option("Strip 1","AmoebaStrips/Strip0000.gif")
group[0][1]=new Option("Strip 2","AmoebaStrips/Strip0001.gif")
(etc.....)
group[1][0]=new Option("Strip 31","AmoebaStrips/Strip0030.gif")
group[1][1]=new Option("Strip 32","AmoebaStrips/Strip0031.gif")
(etc....)
group[2][0]=new Option("Strip 61","AmoebaStrips/Strip0059.gif")
group[2][1]=new Option("Strip 62","AmoebaStrips/Strip0060.gif")
(etc...)
group[3][0]=new Option("Strip 91","AmoebaStrips/Strip0089.gif")
group[3][1]=new Option("Strip 92","AmoebaStrips/Strip0090.gif")
(etc...)
var temp=document.doublecombo.stage2
function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options=new Option(group[x].text,group[x].value)
}
temp.options[0].selected=true
}
function go(){
top.frames["mainFrame"].location=temp.options[temp.selectedIndex].value
}
function getCurrentComicNum(selectEl) {
var selected = selectEl.options[selectEl.selectedIndex].text;
var currentNum = selected.substr(selected.indexOf("/"),selected.indexOf("."));
return parseInt(selected.replace(/^0-9/gi,""));
}
var baseURL = "AmoebaStrips/Strip";
var fileType = ".gif";
function nextComic(selectEl) {
var thisComic = getCurrentComicNum(selectEl);
thisComic++;
thisComic.toString();
while (thisComic.length<3) { thisComic = "0"+thisComic; }
top.frames["mainFrame"].location = baseURL + thisComic + fileType;
}
function prevComic(selectEl) {
var thisComic = getCurrentComicNum(selectEl);
thisComic--;
thisComic.toString();
while (thisComic.length<3) { thisComic = "0"+thisComic; }
top.frames["mainFrame"].location = baseURL + thisComic + fileType;
}
//-->
</script>
http://theamoeba.ontheweb.com http://theamoeba.ontheweb.com My web site (http://theamoeba.ontheweb.com)
I'm not a programmer but I've set up a site for my cartoons.
Basically I have this Java double combo box set up for the archive section. From the first combo box, the user can select a range of strips to be viewed 1-30, 30-60 etc. From the, then propogated second list, the user can select a specific strip.
This works fine.
I've now written some code (untested) on the end of this, that calculates the 'next' strip and the 'previous' strip.
My problem is, I don't know how to insert buttons to make said functions work!
I'd like the user to be able to press either button and be zipped to the strip of their choice.
If the combo's could be updated to show the choice, that would be cool too. Please have a look over at:
The web site (http://theamoeba.ontheweb.com/)
and select the 'Archive' item in the menu at the top of the screen to see what I mean.
Many thanks in advance for anyone kind enough to help.
The code is as follows.......
<form name="doublecombo">
<p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option>Strips 1-30</option>
<option>Strips 31-60</option>
<option>Strips 61-90</option>
<option>Strips 91-120</option>
</select>
<select name="stage2" size="1">
<option value="AmoebaStrips/Strip0000.gif">Strip 1</option>
<option value="AmoebaStrips/Strip0001.gif">Strip 2</option>
<option value="AmoebaStrips/Strip0002.gif">Strip 3</option>
(etc......)
</select>
<input type="button" name="test" value="Go!"
onClick="go()">
</p>
<script>
var groups=document.doublecombo.example.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group=new Array()
group[0][0]=new Option("Strip 1","AmoebaStrips/Strip0000.gif")
group[0][1]=new Option("Strip 2","AmoebaStrips/Strip0001.gif")
(etc.....)
group[1][0]=new Option("Strip 31","AmoebaStrips/Strip0030.gif")
group[1][1]=new Option("Strip 32","AmoebaStrips/Strip0031.gif")
(etc....)
group[2][0]=new Option("Strip 61","AmoebaStrips/Strip0059.gif")
group[2][1]=new Option("Strip 62","AmoebaStrips/Strip0060.gif")
(etc...)
group[3][0]=new Option("Strip 91","AmoebaStrips/Strip0089.gif")
group[3][1]=new Option("Strip 92","AmoebaStrips/Strip0090.gif")
(etc...)
var temp=document.doublecombo.stage2
function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options=new Option(group[x].text,group[x].value)
}
temp.options[0].selected=true
}
function go(){
top.frames["mainFrame"].location=temp.options[temp.selectedIndex].value
}
function getCurrentComicNum(selectEl) {
var selected = selectEl.options[selectEl.selectedIndex].text;
var currentNum = selected.substr(selected.indexOf("/"),selected.indexOf("."));
return parseInt(selected.replace(/^0-9/gi,""));
}
var baseURL = "AmoebaStrips/Strip";
var fileType = ".gif";
function nextComic(selectEl) {
var thisComic = getCurrentComicNum(selectEl);
thisComic++;
thisComic.toString();
while (thisComic.length<3) { thisComic = "0"+thisComic; }
top.frames["mainFrame"].location = baseURL + thisComic + fileType;
}
function prevComic(selectEl) {
var thisComic = getCurrentComicNum(selectEl);
thisComic--;
thisComic.toString();
while (thisComic.length<3) { thisComic = "0"+thisComic; }
top.frames["mainFrame"].location = baseURL + thisComic + fileType;
}
//-->
</script>
http://theamoeba.ontheweb.com http://theamoeba.ontheweb.com My web site (http://theamoeba.ontheweb.com)