Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Putting 'next' button double combo.

    Hello, I'm very much an amature at Java so I'll need a lot of hand-holding but here goes....
    I've used the Cut and Paste version of the Double Combo from this site and changed it slightly to load into a frame as the original didn't.
    So, the first pull down list I can now choose Strips 1-30, 30-60 etc (as it is on a cartoon/comic site) and in the following populated list, choose 1, 2, 3, 4...... etc.
    Now, I've been told that it's all very nice, but a NEXT/PREVIOUS Button would be a good thing to add onto this as quite a lot of people can't be bothered to re-select an option from the second list.
    So, what I need is for a selection to be made as normal, but two other buttons similar to the GO button can be used to move onto the 'next' or 'previous' selection (ie, program rather than actual user input) and re-populate the second list!!

    I understand this is possible as I think this question has been asked before in more technical terms, and, as I said at the beginning I'm, a novice at all this and any cut and paste code would be much appreciated.
    Hope you can help.
    Cheers.
    Paul.

    The code so far is........

    <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>
    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[i]=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")
    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[i]=new Option(group[x][i].text,group[x][i].value)

    }

    temp.options[0].selected=true

    }

    function go(){
    top.frames["mainFrame"].location=temp.options[temp.selectedIndex].value

    }

    //-->
    </script>
    </form>

  • #2
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I wouldn't bother relating next/prev buttons to the select box, unless you're already preselecting the currently displayed page's proper option element.

    I'd just make two new functions, nextComic() and prevComic() that call a third, getCurrentComicNum(), and bump up or down the number.

    example (untested, just typed right into here):

    PHP Code:
    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 3thisComic "0"+thisComic;
        
    top.frames["mainFrame"].location baseURL thisComic fileType);
    }
    function 
    prevComic(selectEl) {
        var 
    thisComic getCurrentComicNum(selectEl);
        
    thisComic--;
        
    thisComic.toString();
        while (
    thisComic.length 3thisComic "0"+thisComic;
        
    top.frames["mainFrame"].location baseURL thisComic fileType);

    You may want to put some failsafe in there to guarantee you don't get a 404, but I think that'll mostly do the trick for you.

  • #3
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks guy for the quick reply, unfortunatly I didn't understand a word of it.
    Where would I paste what you wrote into the script I posted? Is it in PHP? If so, I can't use that as my server won't let me (something to do with security).
    I really would have liked the second drop down list to be re-populated just for the users continuity(?) more than anything.
    If this isn't possible just modifying the original Java with no PHP, I'll either have to:
    a/ scrap the original idea and hate the result or
    b/ leave it as it is and get on the viewers nerves.

    Sorry to be such a dumb ***.
    Hope some one can still help.
    Cheers.
    Paul.

  • #4
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's javascript (I just used the PHP tag for the fun and beauty of color-coding).

    Treat it like regular javascript.

  • #5
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well Choopernickel,
    I finally had time to try that code you posetd in reply to my problem. Nice attempt and it looked like a winner..... but it didn't work. Sorry. I noticed in the code that you gave me, it seems to be adding a zero before the file name string, is that the problem and the files names have two zero, sometimes more..!
    When I run it it (it may not even be pasted in the correct place) it says unexpected ';' in the line I've maked with several exclamation marks below....
    Hope you can help again.
    Cheers.
    Paul.

    <html>
    <head>
    <title>Amoeba Strips Archive</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script>
    if (parent.frames.length==0)
    window.location.replace("StripPageWindow.htm")
    </script>
    </head>
    <BODY BGCOLOR="#FFFFFF">
    <div align="center">
    <p><font face="Arial" size="-2">Choose the strip to view by selecting the month
    from the first drop down menu, followed by the strip name in the second.<br>
    <i>Choose from 99</i></font><font face="Arial" size="-2"><i> strips!</i><br>
    <br>
    <b>Hit GO! To view selection.</b></font></p>
    </div>
    <CENTER>
    <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>
    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; !!!!!!!!THE ZEROS I MENTIONED

    top.frames["mainFrame"].location = baseURL + thisComic + fileType);!!!!!!!!!!!!!!! THIS LINE
    }
    function prevComic(selectEl) {
    var thisComic = getCurrentComicNum(selectEl);
    thisComic--;
    thisComic.toString();
    while (thisComic.length > 3) thisComic = "0"+thisComic; !!!!!!!THE ZEROS AGAIN

    top.frames["mainFrame"].location = baseURL + thisComic + fileType); !!!!!!!!!!!!!!!!!!!!THIS LINE
    }

    var groups=document.doublecombo.example.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group[i]=new Array()

    group[0][0]=new Option("Strip 1","AmoebaStrips/Strip0000.gif")
    group[0][1]=new Option("Strip 2","AmoebaStrips/Strip0001.gif")
    group[0][2]=new Option("Strip 3","AmoebaStrips/Strip0002.gif")
    etc....


    group[1][0]=new Option("Strip 31","AmoebaStrips/Strip0030.gif")
    group[1][1]=new Option("Strip 32","AmoebaStrips/Strip0031.gif")
    group[1][2]=new Option("Strip 33","AmoebaStrips/Strip0032.gif")
    etc......

    group[2][0]=new Option("Strip 61","AmoebaStrips/Strip0059.gif")
    group[2][1]=new Option("Strip 62","AmoebaStrips/Strip0060.gif")
    group[2][2]=new Option("Strip 63","AmoebaStrips/Strip0061.gif")
    group[2][3]=new Option("Strip 64","AmoebaStrips/Strip0062.gif")
    etc...

    group[3][0]=new Option("Strip 91","AmoebaStrips/Strip0089.gif")
    group[3][1]=new Option("Strip 92","AmoebaStrips/Strip0090.gif")
    group[3][2]=new Option("Strip 93","AmoebaStrips/Strip0091.gif")
    group[3][3]=new Option("Strip 94","AmoebaStrips/Strip0092.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[i]=new Option(group[x][i].text,group[x][i].value)

    }

    temp.options[0].selected=true

    }

    function go(){
    top.frames["mainFrame"].location=temp.options[temp.selectedIndex].value

    }

    //-->
    </script>
    </form>
    </CENTER>
    <script language='javascript'>document.write('<img src="http://sitebuilder.freeserve.com/servlets/istat?site=theamoeba&page=/StripsCalenderJan02.htm&outil=ftpweb&n=' + Math.round(Math.random()*100000) + '" width=1 height=1>'); </script>




    </body>
    </html>

  • #6
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello, anybody gonna help my out on this thing...?
    I'm really stuck here.
    Paul.

  • #7
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not-A-Mod Hat On
    NewB, have you ever participated in a voluntary support forum before? We are under no obligation to help you. Especially since you haven't particularly helped us yet.

    That said,
    change the while loops to
    PHP Code:
    while (thisComic.length<3) { thisComic "0"+thisComic; } 
    and delete the closing parinthesis off the other offending lines.

    I apologize for not typing perfect untested code into a message board, but I was of the understanding that you had a text editor, and were capable of reading what was presented to you.

    I don't mean to be harsh, but accept the help you get graciously and return the favor whenever you can, and I'll be pleased not to post in this thread again.

  • #8
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, thanks choppernickle, for the help and the particularly sarcastic reply that accompanied it.

    No, I've not taken part in forum help groups before as I've never needed this kind of help as i'm a cartoonist, not a programmer.

    I do indeed have a text editor/viewer but not knowing what I'm viewing doesn't really help matters.

    I thought the idea of help forums was for people to post help, correct me if I'm wrong.
    Regards,

    Paul.
    PS, still doesn't work.
    Last edited by NewB; 06-11-2003 at 05:13 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •