- Posts: 46
- Thank you received: 0
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
- jerryd
- Topic Author
- Offline
- Senior Member
Less
More
8 years 4 months ago #129551
by jerryd
Thanks alot
jerryd
one drop down depend on other in arraytext using javascript was created 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
Thank you!
Thank you!
Thanks alot
jerryd
Attachments:
The topic has been locked.
- mguerrero
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 1
8 years 4 months ago #129581
by mguerrero
Replied by mguerrero on topic one drop down depend on other in arraytext using javascript
Hi, I think an example like this is what you need in the .php file should do the query and return a value .
Cheers
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: "http://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.
- jerryd
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 46
- Thank you received: 0
8 years 3 months ago #129601
by jerryd
Thanks alot
jerryd
Replied by jerryd on topic one drop down depend on other in arraytext using javascript
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!
Thank!
Thanks alot
jerryd
The topic has been locked.
- mguerrero
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 1
8 years 3 months ago #129605
by mguerrero
Replied by mguerrero on topic one drop down depend on other in arraytext using javascript
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.