BullGuard Antivirus Sale - 60% Off with openElement !
Forum Home Forum Home >

openElement

> Dynamic OE - Databases, etc
  New Posts New Posts RSS Feed - changing dropdown list value accoring to DB query
  FAQ FAQ  Forum Search   Register Register  Login Login

changing dropdown list value accoring to DB query

 Post Reply Post Reply
Author
Message
djju1029 View Drop Down
Senior Member
Senior Member
Avatar

Joined: Aug 02 2016
Location: the US
Status: Offline
Points: 126
Post Options Post Options   Thanks (0) Thanks(0)   Quote djju1029 Quote  Post ReplyReply Direct Link To This Post Topic: changing dropdown list value accoring to DB query
    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  
Back to Top
djju1029 View Drop Down
Senior Member
Senior Member
Avatar

Joined: Aug 02 2016
Location: the US
Status: Offline
Points: 126
Post Options Post Options   Thanks (0) Thanks(0)   Quote djju1029 Quote  Post ReplyReply Direct Link To This Post Posted: Sep 21 2016 at 11:09pm
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!
Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group


Joined: May 31 2012
Status: Offline
Points: 5283
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: Sep 22 2016 at 8:24am
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
Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group


Joined: May 31 2012
Status: Offline
Points: 5283
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: Sep 22 2016 at 8:25am
[I updated the answer above]
Back to Top
djju1029 View Drop Down
Senior Member
Senior Member
Avatar

Joined: Aug 02 2016
Location: the US
Status: Offline
Points: 126
Post Options Post Options   Thanks (0) Thanks(0)   Quote djju1029 Quote  Post ReplyReply Direct Link To This Post Posted: Sep 22 2016 at 3:27pm
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!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.