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 15 of 15
  1. #1
    SPD
    SPD is offline
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Pull down menu generator

    Hello.

    I would like you to rate this script.

    http://www.superprodesign.com/spd/sc.../pllmenu1.html

    Discuss any problem you may find.

    Thank you.

    SPD
    Enjoy!

    http://www.superprodesign.com

    SPD :thumbsup:

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you really need to put:

    <!--Write here the link for option #3 between the "" like in the example below-->

    every time? Why not just have it once at the starting.

  • #3
    SPD
    SPD is offline
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Well. You see.

    I thought that way will be easier to modify for not so advanced people, and that is a good feature. It bothers too much?
    Enjoy!

    http://www.superprodesign.com

    SPD :thumbsup:

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    These lines:

    Code:
    if (op37264.options.selectedIndex>0)location.href=eval("li37264"+op37264.options.selectedIndex+"")
    }
    are a very bad style of coding, the use of eval() in this place is totally unjustified. This snippet does not work in Mozilla, because it is not the proper way to access the value of a selected option element.

    You might also consider to check what number of lines the user prints into your form, feeding a string results in a script error, and a very large number causes IE to freeze.

    If you want me to rate this script... hmh, I think you need to improve a lot. Maybe you should first read how javascript reads option values from a select list and then create your script anew. Good luck.

  • #5
    SPD
    SPD is offline
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    With what should I replace eval(), then?

    I just don't find another way to define the content of that option to point to the selected link.

    The many lines I can find a way with a good use of the for () loop.

    I would be very grateful if you reply with your opinion on how to improve this.

    Thanks in advance.

    SPD
    Enjoy!

    http://www.superprodesign.com

    SPD :thumbsup:

  • #6
    SPD
    SPD is offline
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Hello again...

    Hello again...

    I already got a shorter code.

    What I was trying to say in the beggining, maybe some users misunderstood, is that my main porpose in this script was not to make another 10, 20 or even 40 option pull down menu generator, but to break those limits. The current corrected script produces more than 200 options without crashing the browser (at least from 64 mb P3 667MHZ computer up). I know that the main problem for Mozilla is the line you said, but I couldn't make it otherwise for the porpose I want.

    Nevertheless, as we all know, most people browse with IE for one reason or another, even if Mozilla is undoubtedly a very nice product and we all love it.

    But I had to keep most of the public in mind, for the quantity of users, not for the quality of browsers. Even the people that love Mozilla, nevertheless use also IE, while the people that use IE don't use Mozilla or other browsers (because of the way the Internet is, not because Mozilla is worse in any way...).

    You can check the new updated version without the junk code at least here:

    http://www.superprodesign.com/spd/sc.../pllmenu1.html

    As always, enjoy!

    Another question: Which one is the effect you would like to see the most in a pull down menu. Some examples are: a sound when you select a new option, a image that pops out in another window when you select another option, etc...

    Please let me hear your suggestions and wish list. Maybe I could even fulfill some requests, now or in the future. Also, it is very interesting for me to know.

    Thank to all the users of this forum again.

    SPD
    Enjoy!

    http://www.superprodesign.com

    SPD :thumbsup:

  • #7
    SPD
    SPD is offline
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up For mordred

    Hello.

    Well, the good news are I was succesful in replacing "the" line.

    Test the script again and thank you for letting me know of any problem. If you or any user knows of any problems, please let me know.

    http://www.superprodesign.com/spd/sc.../pllmenu1.html

    The script still supports "unlimited options" (more than 200 for a 64mb RAM and 667 MHZ up computer)...

    Enjoy!

    SPD
    Enjoy!

    http://www.superprodesign.com

    SPD :thumbsup:

  • #8
    SPD
    SPD is offline
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Second question...

    I forgot to state again my second question to the users... I will state it again...

    Another question: Which one is the effect you would like to see the most in a pull down menu. Some examples are: a sound when you select a new option, a image that pops out in another window when you select another option, etc...

    Thank you again.

    SPD
    Enjoy!

    http://www.superprodesign.com

    SPD :thumbsup:

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Frankly, I don't think your script has much improved. Though you accessed the options correctly this time - that's fine.

    But I wonder how useful the output of your script is. Take for example this line:

    Code:
    document.write("<select name='op63934' onchange=nav63934()><option>"+ot63934+"");for (H63934=1;H63934<eval(3)+eval(1);H63934++){document.write("<option value='"+eval("li63934"+H63934)+"'>"+eval("tex63934"+H63934)+"</option>")};document.write("</select>")
    Let me count... there are now 4 eval() statements in your code and not one of them is really needed IMO. Of course, the all-to-gentle scripting engine of IE let's you go away with that, but the semantics of this code are really strange:

    Code:
    for (H63934=1;H63934<eval(3)+eval(1);H63934++){
    3 evaluated is 3, and 1 evaluated is 1, so the result is 4. Why don't just write out 4 as the limit for your for-loop, it's the number I told the script to produce option elements.

    Code:
    document.write("<option value='"+eval("li63934"+H63934)+"'>"+eval("tex63934"+H63934)+"</option>
    Errh... since H63934 is a number, and a string concatenated with a number is a string again and can be concatenated with other strings, what sense does eval() have in this context?
    BTW: Why is the code so obfuscated with those random variable names? Wouldn't it be much better and maintainable in the long run to name your variables "myListItem1" e.g.?

    The biggest problem I see is that the JavaScript generates the option elements, but the pulldown-menu could function with ordinary option elements in HTML too... and how useful is a script that bloats the sourcecode with comments and js variables to save the typing of some HTML elements?

    I hope this doesn't sound too harsh alltogether, but I still think you have some broken windows to fix.

  • #10
    SPD
    SPD is offline
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up To mordred

    Yes, I hear your points.

    It is fine; my intention here is to further learn to develop my skills, so, the oposite, thanks for your time.

    First of all, let me explain to you that, alas, not everybody in the web is well learned to produce script with that HTML facility that you describe.

    If you talk about me scripting a specific thing, fine. Your points are more than correct and I cannot argue.

    But also, you must take in consideration that what I try is to make a "software" so that the user, even if he/she is not experienced in JS at all, will be able to create JS for his/her sites. So you have to view the overall script not as SPD programming for him, but as SPD programming for the widest range of people in the web posible, form the expert that wants a quick solution to the absolute begginer, that only knows to fill the options....

    The generator's idea goes even further than that...

    Even the expert sometimes is in trouble when creating a script, because of the need to make a different function. Say, for example, that you want to program a script that makes a link automatically flash...

    So you make your function my_function()

    If I want to make another flashing link in that same page, I have to make my_function2() for the flash. If I create again the same functions/variables, the script will not work. It is both a loss of time for the expert and a puzzle for the non-Expert or the ones that don't understand the code or why that happens.

    You get the point?

    OK, I see. In this particular case you mean that I could resource to the "this" object.

    The eval(1)+eval(1) mystery is solved by my impossibility to know the options the user is going to select.

    I say, you are 100% right, but this is a different context...

    Let me know what you think...

    About your questions:

    Errh... since H63934 is a number, and a string concatenated with a number is a string again and can be concatenated with other strings, what sense does eval() have in this context?

    Little bit complicated... I tried the other way and didn't work.

    BTW: Why is the code so obfuscated with those random variable names? Wouldn't it be much better and maintainable in the long run to name your variables "myListItem1" e.g.?

    I fear that a user may produce item1 and then return the next day and produce again item1 and include it in the same page (remember not everybody understands), creating a problem. So the random saves me from that...!!
    Enjoy!

    http://www.superprodesign.com

    SPD :thumbsup:

  • #11
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by SPD
    I fear that a user may produce item1 and then return the next day and produce again item1 and include it in the same page (remember not everybody understands), creating a problem. So the random saves me from that...!!
    That's what object-oriented code is for

    http://www.peterbailey.net/dhtml/nav_select.htm

    It would be super-easy to create a wizard to generate the init() function for newbie-users, but even barring that, I think it's pretty straightfoward to use.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #12
    SPD
    SPD is offline
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post About the random number...

    To beetle:

    I see what you say... well, you mean the init() that goes into the body tag?

    Well, I prefer not to use that, since the user has to do extra effort to install the script. I prefer him to copy and paste. That's it...

    But generally talking, I don't see that for the user there is a practical difference some extra numbers. I say, what can the difference be between my_var and my_var435671 for the person... some few bytes?

    It is miliseconds or less for the computer to generate!!!

    Let me know what you think?
    Enjoy!

    http://www.superprodesign.com

    SPD :thumbsup:

  • #13
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can just as easily use

    window.onload = init;

    or

    window.attachEvent( "onload", init );

    or

    window.addEventListener( "load", init, false );

    There is a practical difference in terms of usability. Randomly named varaibles and functions make a script sematically useless and difficult to read. But no, the size of the variable name should have no noticeable effect.

    Personally, I think it's easier to teach a user how to populate an array and initialize a function than to walk them through a process of creating options/values from an absurdly large amount of global variables and commenting. Even still, as I mentioned before, a wizard could easily be created to provide the small amout of code required.

    It's not that your script is bad, it's just not something I'd use or recommend. It's processes go against my feelings about how javascripting (or just programming for that matter) should be done.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #14
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I like to keep this kind of thing real simple, personally:

    <select name="mymenu" onchange="if (this.options[this.selectedIndex] > 0) location=this.options[this.selectedIndex].value">
    <option value="">Pick one yo</option>
    <option value="somepage.htm">somepage</option>
    <option value="somepage2.htm">somepage2</option>
    </select>
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #15
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Why don't you just put every options BEFORE the script appears:

    Title {box}

    How many options {box}

    Then, a different ammount of option boxes appear

    {box 1-option 1}
    {box 2-option 2}
    {box 3-option 3}
    {box 4-option 4}
    {box n-option n} n is the ammount of options the user specified earlier


    Click here ! {link}

    The script appears here {box}



    And there you have it!
    Shawn


  •  

    Posting Permissions

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