Javascript and overriede browse.tpl ..BUG ?!

Author Message

Selmah Maxim

Wednesday 07 December 2005 10:35:25 am

Hi ..

AM trying to override the browse.tpl, ok ... easy to but the javascript is not working, and when i place the same code in another template work fine ... what to do ?!


{literal}
<script language="JavaScript">
var DomYes=document.getElementById?1:0;

function set_child_listbox(parentObject,childObject,childArray,spanToHide) {

	//Clear child listbox
	for(var i=childObject.length;i>0;i--) {
		childObject.options[i] = null;
	} 
	
	childObject.options[0] = new Option("Select Value","");
	var sel_index = parentObject.options[parentObject.selectedIndex].value;
	if (sel_index == "") {
		childObject.disabled = true;
	} else {
		childObject.disabled = false;
		var childIndex = 1;
		for (i = 0; i < childArray.length; i++) {
			if (childArray[i][1] == sel_index) {
				childObject.options[childIndex] = new Option(childArray[i][2], childArray[i][0]);
				childIndex++;
			}
		}
	}
	//Select first option
	childObject.selectedIndex = 0;

	//Hide dependent grid
	if (spanToHide != "") {
		if (DomYes) {
  			document.getElementById(spanToHide).style.display="none";
		} else {
			document.all[spanToHide].style.display="none";
		}
	}
}

function reload_page() {
  var sel_index = document.SelectCarCat.s_category_id.options[document.SelectCarCat.s_category_id.selectedIndex].value;
  var sel_subindex = document.SelectCarCat.SelectedNodeIDArray.options[document.SelectCarCat.SelectedNodeIDArray.selectedIndex].value;
  if (sel_subindex != "") {
	 document.location.href = document.location.pathname + "?" + "SelectedNodeIDArray=" + sel_subindex+"&s_category_id=" + sel_index;
  }
}

function disable_child_listbox(spanToHide) {
  
  //Disable second listbox 
  if (document.SelectCarCat.s_category_id.selectedIndex == "") {
     document.SelectCarCat.SelectedNodeIDArray.disabled = true;
  }	

  //Hide dependent grid 
  if (document.SelectCarCat.SelectedNodeIDArray.selectedIndex == "") {
	if (spanToHide != "") {
		if (DomYes) {
			document.getElementById(spanToHide).style.display="none";
		} else {
			document.all[spanToHide].style.display="none";
		}
	}
  }	
}

window.onload = function() {
	disable_child_listbox("Products");
}
{/literal}





{let $car_make_cats=fetch('content','list',hash(parent_node_id,84,
                                   class_filter_type,include,
                                   class_filter_array,array(22)))
								   }
var Product = new Array( 
{section loop=$car_make_cats var=Make}
	
		{let $car_made_cats=fetch('content','list',hash(parent_node_id,$Make.node_id,
                                   class_filter_type,include,
                                   class_filter_array,array(17)))
		}
			{section loop=$car_made_cats var=Made}
								new Array({$Made.node_id},{$Make.node_id},'{$Made.name}')
								{*section show=qe($Made.parent.children_count,$Made.number)*},{*/section*}
			{/section}
		{/let}  

{/section}
new Array(999,888,'xxxx')
);
{/let}


</script>

      
<form action="/car/index.php/automobile/content/action" method="post" name="SelectCarCat">

  	<div  ID="carmakediv">
              <select name="car_make" size="5" onchange="set_child_listbox(this, document.SelectCarCat.NodeID,Product,'Products');" style="position:absolute;width:136px;height:95px;top:-4px;left:-3px;">
  <option value="" selected>Select Car Make</option>
				{let $car_make_cats=fetch('content','list',hash(parent_node_id,84,
                                   class_filter_type,include,
                                   class_filter_array,array(22)))
								   }

					{section loop=$car_make_cats var=Make}
						<OPTION VALUE="{$Make.node_id}" >{$Make.name}</OPTION>
					{/section}

      </select>
  </div>
			  {/let}
			<div  ID="carmodeldiv" >
              <select name="NodeID" size="5"  style="position:absolute;width:136px;height:95px;top:-4px;left:-3px;" >
			  <OPTION VALUE="" style="background-color: red;color:#000000;">Select Car Made</OPTION>
			  </select>
  			</div>

 <div style="	padding: 55px; "></div>


<input type="hidden" name="BrowseActionName" value="{$browse.action_name}" />
<input class="button" type="submit" name="SelectButton" value="{'Select'|i18n('design/standard/content/browse')}" />
 <input class="button" type="submit" name="BrowseCancelButton" value="{'Cancel'|i18n( 'design/standard/content/browse' )}" />
</form>


This script will show the child cats when u select the main ... any hope ?!

Thanks in advance.

Selmah Maxim

Wednesday 07 December 2005 12:14:24 pm

I know why is not working .. its give me back undefined object about the snd child select .. buts its there ... and with normal html work fine .,... I cann`t think why ... spent 3 hours to slove it ... and the problem my client asking it like this :(

Selmah Maxim

Wednesday 07 December 2005 12:56:09 pm

OK ... I found it ... 2 form ... same name ! :)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 08:11:03
Script start
Timing: Jan 31 2025 08:11:03
Module start 'layout'
Timing: Jan 31 2025 08:11:03
Module start 'content'
Timing: Jan 31 2025 08:11:03
Module end 'content'
Timing: Jan 31 2025 08:11:03
Script end

Main resources:

Total runtime0.0148 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.2500151.2266
Module start 'layout' 0.00510.0025 739.476636.6797
Module start 'content' 0.00770.0060 776.156394.1094
Module end 'content' 0.01370.0011 870.265633.9922
Script end 0.0148  904.2578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002315.4279140.0002
Check MTime0.00117.3616140.0001
Mysql Total
Database connection0.00085.696210.0008
Mysqli_queries0.002315.556730.0008
Looping result0.00000.080510.0000
Template Total0.00085.710.0008
Template load0.00074.595610.0007
Template processing0.00021.073310.0002
Override
Cache load0.00053.150610.0005
General
dbfile0.002214.951680.0003
String conversion0.00000.046740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs