Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

one drop down depend on other in arraytext using javascript

More
10 years 9 months ago #129551 by jerryd
hi every one i really need a support i am not close for java script and by t partner support i am preparing drop down using java script and i need to connect each drop box like a condition in lime survey eg:when i select region from level it have to only show me expert from function box when i select Zone from level it have to be only list DA from function so please help me with this i have finish this before December 24 /2015

File Attachment:

File Name: limesurvey...1(1).lss
File Size:25.91 KB


File Attachment:

File Name: limesurvey...1(1).lss
File Size:25.91 KB

Thank you!

Thanks alot
jerryd
The topic has been locked.
More
10 years 9 months ago #129581 by mguerrero
Hi, I think an example like this is what you need in the .php file should do the query and return a value .
Code:
<script> var sid = {SID}; var remove_zone = {SID_REMOVE}; $("#answer229618X650X26215").change(function() { var region = $(this).val(); $("#answer"+remove_zone+ "option").remove(); $("#answer"+zone).html("<option value='' selected='selected'>Text placeholder example..</option>"); $.ajax({ type: "GET", url: "https://you_url/get_zones.php", data: "id_region="+region, }).done(function (zone){ $.each(zone, function(i) { $('#answer'+remove_zone).append("<option value=\""+zone[i].codigo_zone+"\">"+zone[i].zone+"<\/option>"); }); }); }); </script>

Cheers
The topic has been locked.
More
10 years 9 months ago #129601 by jerryd
Thanks a lot for your help and could you please were did i get this .php file or where did i put? their are lots of .php file in it i don't have further knowledge about lime survey please?



Thank!

Thanks alot
jerryd
The topic has been locked.
More
10 years 9 months ago #129605 by mguerrero
Hi jerryd , you can put the file in the root of / www , you should also have tables regions and zones in you database.

Code:
<?php require 'database.php'; $region = $_GET['id_region']; $sql = "SELECT code_zone,zone FROM zones where id_region = $region"; $result = mysqli_query($con,$sql); header('Content-Type: application/json'); $j = array(); while ($row = mysqli_fetch_array($result)) { $j[] = $row; } echo json_encode($j); mysqli_close($con); ?>
The topic has been locked.
Moderators: holch, tpartner

Lime-years ahead

Online-surveys for every purse and purpose