changing dropdown list value accoring to DB query |
Post Reply |
Author | |
djju1029
Senior Member Joined: Aug 02 2016 Location: the US Status: Offline Points: 126 |
Post Options
Thanks(0)
Posted: Sep 21 2016 at 5:28pm |
Dear OE team,
I use a drop down list form like this: <div id="WEd8e6c9ba03" class="BaseDiv RWidth OEWEListBoxV2 OESK_WEListBox2_Default" style="z-index:2016"> <div class="OESZ OESZ_DivContent OESZG_WEd8e6c9ba03"> <select name="WEd8e6c9ba03" class="OESZ OESZ_ListBox OESZG_WEd8e6c9ba03 OEDynTag0"> <option value="1" class="OESZ OESZ_Options OESZG_WEd8e6c9ba03">ON</option> <option value="0" class="OESZ OESZ_Options OESZG_WEd8e6c9ba03">OFF</option> </select> </div> </div> And I want to display this option according to queried value of table, such as: if ($read[0]['despec_sys_a'] == 0) { <option value="0" class="OESZ OESZ_Options OESZG_WEd8e6c9ba03">OFF</option> } else { <option value="1" class="OESZ OESZ_Options OESZG_WEd8e6c9ba03">ON</option> }And I want to update to value from drop down list if user changes the value, for instance, from ON to OFF or vice versa. How can I implement this code on OE? I appreciate your kind reply. DJ Joo |
|
djju1029
Senior Member Joined: Aug 02 2016 Location: the US Status: Offline Points: 126 |
Post Options
Thanks(0)
|
I coded like following:
<div id="WEd8e6c9ba03" class="BaseDiv RWidth OEWEListBoxV2 OESK_WEListBox2_Default" style="z-index:2016"> <div class="OESZ OESZ_DivContent OESZG_WEd8e6c9ba03"> <select name="WEd8e6c9ba03" class="OESZ OESZ_ListBox OESZG_WEd8e6c9ba03 OEDynTag0"> <option value="1" class="OESZ OESZ_Options OESZG_WEd8e6c9ba03">ON</option> <option value="0" class="OESZ OESZ_Options OESZG_WEd8e6c9ba03">OFF</option> </select> </div> </div> <div id="WE2e71bd5b59 " class="BaseDiv RWidth OEWEListBoxV2 OESK_WEListBox2_Default" style="z-index:2016"> <div class="OESZ OESZ_DivContent OESZG_WE2e71bd5b59 "> <select name="WE2e71bd5b59 " class="OESZ OESZ_ListBox OESZG_WE
2e71bd5b59 OEDynTag0"> <option value="1" class="OESZ OESZ_Options OESZG_WE2e71bd5b59 ">ON</option> <option value="0" class="OESZ OESZ_Options OESZG_WE2e71bd5b59 ">OFF</option> </select> </div> </div> <script type="text/javascript"> $(function() { $('#WEd8e6c9ba03 select, option').val("<?php echo $read[0]['despec_sys_a']; ?>"); // dropdown list A $('#WE2e71bd5b59 select, option').val("<?php echo $read[0]['despec_sys_b']; ?>"); // dropdown list B }); </script> However, list A is changed according to arrat properly but list B isn't. I am in a chaos.....help me!
|
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(0)
|
Hi.
Did you check the value in $read[0]['despec_sys_b']? Add somewhere (in a Code Block Visual for example) var_dump($read[0]) to be sure the values are there. The Javascript code looks incorrect to me, it should be just $('#WEd8e6c9ba03 select') and not $('#WEd8e6c9ba03 select, option'). Edited by Dmit OE - Sep 22 2016 at 8:24am |
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(0)
|
[I updated the answer above]
|
|
djju1029
Senior Member Joined: Aug 02 2016 Location: the US Status: Offline Points: 126 |
Post Options
Thanks(0)
|
Thanks, I did it with your code.
$(function() { $('#WEd8e6c9ba03 select').val("<?php echo $read[0]['despec_sys_a']; ?>"); $('#WE2e71bd5b59 select').val("<?php echo $read[0]['despec_sys_b']; ?>"); }); I thought I did that code method and it didnot work. But, it worked. I feel as if I were possessed ??? Anyway, Thank you!
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |