mptwoadmin
Programmer
Can someone shed some light on what I am missing..I am trying to clone a select box that shows/hides div based on the value of the selection. I can get the first drop down to work and show the correct div..but when I clone a div the next select does not show the div..I am pulling my hair out: well I have not hair.
Thank You in advance.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Recipe Builder</title>
<script src=" type="text/javascript" charset="utf-8"></script>
<script language="javascript" src="editinplace.js"></script>
<script type="text/javascript" src="jquery-1.4.min.js"></script>
<script type="text/javascript" src="jquery.sheepItPlugin.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var addressesForm = $("#person_addresses").sheepIt({
separator: '',
allowRemoveLast: true,
allowRemoveCurrent: true,
allowRemoveAll: true,
allowAdd: true,
allowAddN: true,
// Limits
maxFormsCount: 50,//max number of recipe steps
minFormsCount: 0,
iniFormsCount: 1,
nestedForms: [
]
});
});
</script>
<script type="text/javascript">
/*<![CDATA[*/
function Select(sel,id,nu){
document.getElementById(id).style.display=sel.selectedIndex==nu?'block':'none';
}
/*]]>*/
</script>
<script type="text/javascript">
function showHide(id){
el = document.getElementById(id);
el.style.display = (el.style.display != 'block')? 'block' : 'none';
}
</script>
<script>
$(function() {
$("form").submit(function() {
$(this).find(":input").filter(function(){ return !this.value; }).attr("disabled", "disabled");
return true; // ensure form still submits
});
});
</script>
<style>
body
{
background: #A9B7FA;
}
a {
text-decoration:underline;
color:#00F;
cursorointer;
}
fieldset {
padding: 1em;
font:80%/1 sans-serif;
width: 550px;
margin: 0 auto;
text-align: left;
position: relative;
background-color:#ececec !important;
display: table-column;
}
fieldset legend {
position: absolute;
top: -0.5em;
left: 0.5em;
font-size: 18px;
font:125%/1 sans-serif;
color: black;
}
label {
float:left;
width:50%;
margin-right:4.0em;
padding-top:0.2em;
text-align:left;
font-weight:bold;
}
.controls div, .controls div input {
float:left;
margin-right: 10px;
}
</style>
<script>
$(document).ready( function() {
$("select").change(function(){
var divId = $(this).find(":selected").attr("data-div-id");
$(".container").hide();
$("#" + divId).show();
alert("#" + divId);
});
});
</script>
</head>
<body>
<!--- get recipe ingredients --->
<cfquery name="_ingredients" datasource="mixroom">
select ingredient_name, value, trigger_type
from qa_ingredients
</cfquery>
<!--- get recipe measurements --->
<cfquery name="_measurements" datasource="mixroom">
select measure_name, type
from qa_measurements
</cfquery>
<cfset onchange_list="">
<cfloop query="_measurements">
<cfset onchange_list = listappend(onchange_list,"Select(this,'<cfoutput>#measure_name#</cfoutput>_##index##',<cfoutput>#type#</cfoutput>);"," ")>
</cfloop>
<form action="" method="post" enctype="application/x- name="myForm" id="myForm">
<fieldset>
<legend><div class="editme"> Recipe #01</div></legend>
<div id="person_addresses">
<!-- Form template-->
<div id="person_addresses_template">
<p name="test">
<br>
<label for="selector">Process Step <span id="person_addresses_label"> </span> </label>
<select class="selector_#index#" name="selector" id="test">
<option data-div-id="div0" value="" selected>Select Step</option>
<cfloop query="_ingredients">
<option data-div-id="div<cfoutput>#trigger_type#</cfoutput>_#index#"><cfoutput>#ingredient_name#</cfoutput>
div<cfoutput>#trigger_type#</cfoutput>_#index#
</cfloop>
</select>
<a id="person_addresses_remove_current">
<img class="delete" src="images/cross.png" width="16" height="16" border="0">
</a>
<cfloop query="_measurements">
<div id="div<cfoutput>#type#</cfoutput>_#index#" class="container" style="display:none"><cfoutput>#Measure_Name#</cfoutput></div>
<br>
div<cfoutput>#type#</cfoutput>_#index#
</cfloop>
</p>
</div>
<!-- No forms template -->
<div id="person_addresses_noforms_template">No Process Steps</div>
<!-- /No forms template -->
<br>
<!-- Controls -->
<div id="person_addresses_controls" class="controls">
<div id="person_addresses_add"><input type="Button" value="Add Step"></div>
<div id="person_addresses_remove_last"><input type="Button" value="Remove Step"></div>
<div id="person_addresses_remove_all"><input type="Button" value="Remove All Steps"></div>
<div id="person_addresses_submit"><input type=submit name=submit value=submit class="submit-button"></div>
</div>
<!-- /Controls -->
</fieldset>
</div>
<input type="Hidden" id="recipe_name" name="recipe_name">
</form>
</body>
</html>
Thank You in advance.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Recipe Builder</title>
<script src=" type="text/javascript" charset="utf-8"></script>
<script language="javascript" src="editinplace.js"></script>
<script type="text/javascript" src="jquery-1.4.min.js"></script>
<script type="text/javascript" src="jquery.sheepItPlugin.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var addressesForm = $("#person_addresses").sheepIt({
separator: '',
allowRemoveLast: true,
allowRemoveCurrent: true,
allowRemoveAll: true,
allowAdd: true,
allowAddN: true,
// Limits
maxFormsCount: 50,//max number of recipe steps
minFormsCount: 0,
iniFormsCount: 1,
nestedForms: [
]
});
});
</script>
<script type="text/javascript">
/*<![CDATA[*/
function Select(sel,id,nu){
document.getElementById(id).style.display=sel.selectedIndex==nu?'block':'none';
}
/*]]>*/
</script>
<script type="text/javascript">
function showHide(id){
el = document.getElementById(id);
el.style.display = (el.style.display != 'block')? 'block' : 'none';
}
</script>
<script>
$(function() {
$("form").submit(function() {
$(this).find(":input").filter(function(){ return !this.value; }).attr("disabled", "disabled");
return true; // ensure form still submits
});
});
</script>
<style>
body
{
background: #A9B7FA;
}
a {
text-decoration:underline;
color:#00F;
cursorointer;
}
fieldset {
padding: 1em;
font:80%/1 sans-serif;
width: 550px;
margin: 0 auto;
text-align: left;
position: relative;
background-color:#ececec !important;
display: table-column;
}
fieldset legend {
position: absolute;
top: -0.5em;
left: 0.5em;
font-size: 18px;
font:125%/1 sans-serif;
color: black;
}
label {
float:left;
width:50%;
margin-right:4.0em;
padding-top:0.2em;
text-align:left;
font-weight:bold;
}
.controls div, .controls div input {
float:left;
margin-right: 10px;
}
</style>
<script>
$(document).ready( function() {
$("select").change(function(){
var divId = $(this).find(":selected").attr("data-div-id");
$(".container").hide();
$("#" + divId).show();
alert("#" + divId);
});
});
</script>
</head>
<body>
<!--- get recipe ingredients --->
<cfquery name="_ingredients" datasource="mixroom">
select ingredient_name, value, trigger_type
from qa_ingredients
</cfquery>
<!--- get recipe measurements --->
<cfquery name="_measurements" datasource="mixroom">
select measure_name, type
from qa_measurements
</cfquery>
<cfset onchange_list="">
<cfloop query="_measurements">
<cfset onchange_list = listappend(onchange_list,"Select(this,'<cfoutput>#measure_name#</cfoutput>_##index##',<cfoutput>#type#</cfoutput>);"," ")>
</cfloop>
<form action="" method="post" enctype="application/x- name="myForm" id="myForm">
<fieldset>
<legend><div class="editme"> Recipe #01</div></legend>
<div id="person_addresses">
<!-- Form template-->
<div id="person_addresses_template">
<p name="test">
<br>
<label for="selector">Process Step <span id="person_addresses_label"> </span> </label>
<select class="selector_#index#" name="selector" id="test">
<option data-div-id="div0" value="" selected>Select Step</option>
<cfloop query="_ingredients">
<option data-div-id="div<cfoutput>#trigger_type#</cfoutput>_#index#"><cfoutput>#ingredient_name#</cfoutput>
div<cfoutput>#trigger_type#</cfoutput>_#index#
</cfloop>
</select>
<a id="person_addresses_remove_current">
<img class="delete" src="images/cross.png" width="16" height="16" border="0">
</a>
<cfloop query="_measurements">
<div id="div<cfoutput>#type#</cfoutput>_#index#" class="container" style="display:none"><cfoutput>#Measure_Name#</cfoutput></div>
<br>
div<cfoutput>#type#</cfoutput>_#index#
</cfloop>
</p>
</div>
<!-- No forms template -->
<div id="person_addresses_noforms_template">No Process Steps</div>
<!-- /No forms template -->
<br>
<!-- Controls -->
<div id="person_addresses_controls" class="controls">
<div id="person_addresses_add"><input type="Button" value="Add Step"></div>
<div id="person_addresses_remove_last"><input type="Button" value="Remove Step"></div>
<div id="person_addresses_remove_all"><input type="Button" value="Remove All Steps"></div>
<div id="person_addresses_submit"><input type=submit name=submit value=submit class="submit-button"></div>
</div>
<!-- /Controls -->
</fieldset>
</div>
<input type="Hidden" id="recipe_name" name="recipe_name">
</form>
</body>
</html>