Results 1 to 6 of 6

Thread: Could use a little help

  1. #1
    Join Date
    Jul 2010

    Could use a little help

    Hi. As you see, I'm a newbie in this forum, although I've found some pretty great stuff here already, so I'm sure I'll be sticking around for quite some time. Now I've been doing web-development for about 4 years, as a full-time job, and played with it for the last 12 years. So, I'm not new to the web or how it works. I specialize in Zen-Cart.

    O.k. Now that that's out of the way I'll explain my situation. I've never learned Java, and I know I need to. This looks like a great place to start. But, what I need to do is display an image based on an attribute selection from a dropdown menu.

    To explain a little more in detail:

    On a products page, the user must select a font to be used. The dropdown (attribute ID 49) is set to "5 year Old" font (option value 336) by default. I need this to display "5yrold.jpg"....which I can do. Now, the user selects the last font on the list....Wedding Text BT (option value 385), in which the image needs to change appropriately to "wed_txt.jpg" upon selection so the user can see the font they're getting. I also have a link for them to view all fonts all at once, using Java (although I can't get the image to come up full size in the new window.....it's small with a magnifying glass. Maybe somebody could tell me how to fix this, as well?), but I really need to get this done, if somebody could show me an example, or point me to the right place on this site......as this place is HUGE! and there's so many scripts for so many things.

    I would really appreciate any info on this. And if you look me up in the Zen-Cart Forums (same user Nick), you'll see that I'm not one of those "come get what I need and leave types". I'll be here for years to come, and when I learn Java......and I WILL.....I will be right here sharing what I've learned. As that's how a forum like this is supposed to be.......in MY opinion.


  2. #2
    First of all, if you're looking for Java knowledge, you're looking in the wrong place. This section is for JavaScript, which is not the same as Java.
    Java can also be used to design websites, so try to separate both.

    I assume you're talking about Javascript.
    So you're looking for a way to make the selection of a dropdown-list item display the right image.

    Here's some code to make that selection:
    HTML Code:
    <SELECT id="fontSel" onChange="changePicture(this.value);">
    In the headers, add the function:
    function changePicture(pValue)
        var vSelection = "5yrold.jpg";
            case "385": vSelection = "wed_txt.jpg";
            case ...
            //add all images here
        document.getElementById("imagethathastochange").src = vSelection;
    where imagethathastochange is the ID of the image you want to use.

    It'd be a lot easier if you would use the image-filenames as values for the selectionbox, though...

  3. #3
    Join Date
    Jul 2010
    Thank you Trollsplatterer......and yes, I did mean Javascript...sorry.

    I really appreciate this. I will try this and let you know how it goes.

    Now, what exactly did you mean here: "use the image-filenames as values for the selectionbox"? Change the image name from "5yrold.jpg" to........what, something "f001.jpg"?

  4. #4
    You can make the values of the selection box so that you can use this value to compose the filename directly, without writing a separate piece of code for each selection item.

    You could use the filename as value:
    HTML Code:
    <option value="wed_txt.jpg">Wedding Text BT</option>
    function changePicture(pValue)
        if(pValue != "")
            document.getElementById("imagethathastochange").src = pValue;
            document.getElementById("imagethathastochange").src = "5yrold.jpg";
    If all images have the same file extension, you can leave it out, like this:
    HTML Code:
    <option value="wed_txt">Wedding Text BT</option>
    function changePicture(pValue)
        if(pValue != "")
            document.getElementById("imagethathastochange").src = pValue + ".jpg";
            document.getElementById("imagethathastochange").src = "5yrold.jpg";

  5. #5
    Join Date
    Jul 2010

    Hey, Troll....

    You though I was gone for good, didn't you? This just got put on the back burner for a little while.
    Just letting you know that I DID get this accomplished with your help and the help of a Zen-Cart forum member. They knew ZC's files pretty good, and that always helps.

    I just wanted to drop in and say thank you so much for your help in this.

    I am off now to take my journey down javascript lane to see what I can learn and who I can meet along the way.......I hear it's a long road.

    Thanks again,

    If anybody here wants/needs to know exactly how this is done in a Zen-Cart, I'd be happy to post the proper steps involved.
    Last edited by Get Em Fast; 09-20-2010 at 03:06 AM.

  6. #6
    Well, I'll be honest, I'm a bit too active online to keep track of who does and who doesn't react to the messages I write on forums.
    I'm glad to hear that your problem was solved, though.

    Good luck with your journey.
    It's not just a long road, it's an eternal one, because Javascript is a living thing, it evolves and so must we, developers. But once you get the hang of it, it's really just the art of combining your programming skills with the extra information you can find all over the internet.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.14582 seconds
  • Memory Usage 2,893KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_code
  • (3)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates