Select Statement to loop through another javascript -
okay have select statement needs populate loop in javascript. have very basic knowledge of js. have basic coldfusion here using. problem 1 client side , other server-side.
i need first select statement loop through cfloop inside javascript. need somehow change javascript loop (where says $(document).ready(function(){). don't know how. can help?
<cfoutput> <script type='text/javascript' src='/jquery-1.8.2.js'></script> <script type="text/javascript"> function changehiddeninput (objdropdown) { var objhidden = document.getelementbyid("hiddeninput"); objhidden.value = objdropdown.value; } </script> </head> <body> <cfquery name="types" datasource="dsn"> select taking.*, type.* taking inner join type on taking.taking_typeid = type.type_id order type_id </cfquery> <form>how many change? <select id="dropdown" name="dropdown" onchange="changehiddeninput(this)"> <cfloop index="abc" from="1" to="12" step="1"> <option value="#abc#">#abc#</option> </cfloop> </select> <input type="text" name="hiddeninput" id="hiddeninput" value="" /> </form> <br> <br> <cfset changing=4> <script type="text/javascript"> $(document).ready(function(){ <cfloop index="i" from="1" to="#changing#" step="1"> $('.box#i#').hide(); $('##dropdown#i#').change(function() { $('.box#i#').hide(); $('##div' + $(this).val()).show(); }); </cfloop> }); </script> <form> <cfloop index="j" from="1" to="#changing#" step="1"> <select id="dropdown#j#" name="dropdown#j#"> <option value="0">choose</option> <cfloop query="types" startrow="1" endrow="#types.recordcount#"> <option value="area#j##type_id#">change on #type_name#</option> </cfloop> </select> <br> <cfloop query="types" startrow="1" endrow="#types.recordcount#"> <div id="divarea#j##type_id#" class="box#j#"> <cfquery name="getquestions" datasource="dsn"> select questions.* questions questions_orgid=1 , questions_typeid=#types.type_id# order questions_rank </cfquery> <cfloop query="getquestions"> #questions_question#<br> </cfloop> </div> </cfloop> <br> <br> </cfloop> </form> </cfoutput>
i'm not entirely sure you're trying do. turn this:
$(document).ready(function(){ <cfloop index="i" from="1" to="#changing#" step="1"> $('.box#i#').hide(); $('##dropdown#i#').change(function() { $('.box#i#').hide(); $('##div' + $(this).val()).show(); }); </cfloop> });
into like:
$(document).ready(function(){ (var = 1; <= #changing#; i++) { $('.box' + i).hide(); $('##dropdown' + i).change(function() { $('.box' + i).hide(); $('##div' + $(this).val()).show(); }); } });
update: in fact sounds it's entirely js solution?
function changehiddeninput (objdropdown) { (var = 1; <= objdropdown.value; i++) { $('.box' + i).hide(); $('##dropdown' + i).change(function() { $('.box' + i).hide(); $('##div' + $(this).val()).show(); }); } }
Comments
Post a Comment