Results 1 to 3 of 3
  1. #1
    burfodus is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default partially working script

    Hello guys and gals,

    Im new to javascript, and im creating a site that requires a few scripts on the same page, however, on seems to return strange results based on its identifier, sometimes working fully, sometimes for one item or the first few.

    web address is
    Zaks Custom Cues | Zaks Custom Cues | Quality Handcrafted Pool and Snooker Cues

    you will see on tab 'main splice' all toggle images work and as do their targets - go to tab 'four splice' and you will see the first item works only. (targets not loaded yet for this tab) and same again for the partially finished 'badges' tab.

    changing the identifier from groupone to grouptwo switches these states and sometimes returns strange results like the first 9 or 10 working only.

    the site is based in php, on a xoops platform, and this problem has been killing me for 5 days straight now!

    the script seems simple enough
    Java Code:
    	// toggle script
    function toggleany(here,suffix,imagenum)
    {
        var group = document.getElementById("group" + suffix);
        var Sets = group.getElementsByTagName("a");
        for ( x = 0 ; x < Sets.length ; ++x )
        {
            var alink = Sets[x]; /* get reference to one a tag */
            var images = alink.getElementsByTagName("img"); /* find images in that tag */
    
            /* hide or show the select.png depending on which clicked */
            document.getElementById("cbselectortoggle" + suffix + x).style.visibility = ( x == imagenum ) ? "visible" : "hidden";
    
            /* ditto for the contentDiv that matches suffix and imagenum */
            document.getElementById("contentDiv" + suffix + x).style.display = ( x == imagenum ) ? "block" : "none";
        }
    }
    and the output code for first two entries of the working tab...
    XML Code:
    <ul id="mainsplice" class="hide">
    	<li>
    		<div id="groupop1">
    			<div class="cbselector" id="popup">
    				<a onclick="javascript:toggleany(this,'op1',0 ); emailone='variableOne0';">
    					<img class="toggleimage" id="cbselectortoggleop10" src="images/cb/select.png" style="visibility: hidden;" />
    					<img id="cbtimbericon" src="images/cb/timbers/icons/1.png" />
    					<em>Gabon Ebony</em>
    					<span>
    					     <em class="spanem">Gabon Ebony</em>
    					     <strong>Diospyros crassiflora</strong>
    					     <img src="images/cb/timbers/icons/1.png" />
    					     <small>From equatorial Africa, Gabon Ebony is usually found in wet lowlands near rivers and swaps. Devoid of color, Gabon Ebony has ink black with lighter streaks. Only a small percentage of Ebony (three to five percent) produce the highest quality jet black Ebony. Most pieces contain 50-70% sapwood with d....</small>
    					     <b>Hardness = 3220</b>
    					</span>
    				</a>
    			</div>
    			<div class="cbselector" id="popup">
    				<a onclick="javascript:toggleany(this,'op1',1 ); emailone='variableOne1';">
    					<img class="toggleimage" id="cbselectortoggleop11" src="images/cb/select.png" style="visibility: hidden;" />
    					<img id="cbtimbericon" src="images/cb/timbers/icons/2.png" />
    					<em>Purpleheart</em>
    					<span>
    						<em class="spanem">Purpleheart</em>
    						<strong>Peltogyne paniculata</strong>
    						<img src="images/cb/timbers/icons/2.png" />
    						<small>A brilliantly colored hardwood from South America, Purpleheart is very popular for its deep purple color. Ideal for inlay, marquetry, and other fine articles. Occasionally the trees produce either fiddleback or a ropey mottled curl from interlocked grain. The color is a pale brown when freshly cut, ....</small>
    						<b>Hardness = 2710</b>
    					</span>
    				</a>
    			</div>
      		        <div id="spanclear"></div>	
     		</div>
             </li>
    </ul>
    and for the non working code
    XML Code:
    <ul id="foursplice" class="hide">
          <li>
    		<div id="groupicons">
    			<div class="cbselector" id="popup">
    				<a onclick="javascript:toggleany(this,'icons','0' ); emailone='variableOne0';">
    					<img class="toggleimage" id="cbselectortoggleicons0" src="images/cb/select.png" style="visibility: hidden;" />
    					<img id="cbtimbericon" src="images/cb/timbers/icons/1.png" />
    					<em>Gabon Ebony</em>
    					<span>
    						<em class="spanem">Gabon Ebony</em>
    						<strong>Diospyros crassiflora</strong>
    						<img src="images/cb/timbers/icons/1.png" />
    						<small>From equatorial Africa, Gabon Ebony is usually found in wet lowlands near rivers and swaps. Devoid of color, Gabon Ebony has ink black with lighter streaks. Only a small percentage of Ebony (three to five percent) produce the highest quality jet black Ebony. Most pieces contain 50-70% sapwood with d....</small>
    						<b>Hardness = 3220</b>
    					</span>
    				</a>
    			</div>
    			<div class="cbselector" id="popup">
    				<a onclick="javascript:toggleany(this,'icons','1' ); emailone='variableOne1';">
    					<img class="toggleimage" id="cbselectortoggleicons1" src="images/cb/select.png" style="visibility: hidden;" />
    					<img id="cbtimbericon" src="images/cb/timbers/icons/2.png" />
    					<em>Purpleheart</em>
    					<span>
    						<em class="spanem">Purpleheart</em>
    						<strong>Peltogyne paniculata</strong>
    						<img src="images/cb/timbers/icons/2.png" />
    						<small>A brilliantly colored hardwood from South America, Purpleheart is very popular for its deep purple color. Ideal for inlay, marquetry, and other fine articles. Occasionally the trees produce either fiddleback or a ropey mottled curl from interlocked grain. The color is a pale brown when freshly cut, ....</small>
    						<b>Hardness = 2710</b>
    					</span>
    				</a>
    			</div>
    			<div id="spanclear"></div>	
     		</div>
              </li>    		
    </ul>
    thank you advance
    steve

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,371
    Blog Entries
    7
    Rep Power
    20

    Default Re: partially working script

    You must've taken the wrong exit, because this is a Java forum; Javascript and Java are two completely different languages ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    burfodus is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: partially working script

    oh, whoopsie!

    sorry bout that
    sb..

Similar Threads

  1. Script not working with IE7
    By sfphoto in forum New To Java
    Replies: 1
    Last Post: 12-13-2010, 05:08 PM
  2. JTable update only partially successful
    By assel in forum AWT / Swing
    Replies: 0
    Last Post: 12-02-2010, 11:37 PM
  3. Fill in rectangle partially (clip?)
    By OBLITERATOR in forum New To Java
    Replies: 1
    Last Post: 03-07-2010, 04:59 AM
  4. JSP partially renders sometimes
    By lisalu22 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-23-2010, 05:45 PM
  5. JSP send mail script not working.
    By profuse in forum Java Applets
    Replies: 1
    Last Post: 05-27-2008, 06:37 AM

Posting Permissions

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