mtsoulis
Posts: 17
|
Posted: 07/31/2016, 1:27 PM |
|
Hi guys!
I'm beginner and sorry me for my questions.. (sometimes silly questions )
I have the editable grid "mystudents" and the textbox "stsemister"
I have also the independent listbox "semisters"
I wish, when I choose the right semister from the listbox "semisters", the textbox "stsemister" get the same value for all my records in this editable grid.
I will appreciate if your answer includes your instructions and the necessary code.
Thanks in advance!
Miltos, Greece
_________________
Miltos-Greece |
|
|
MichaelMcDonald
Posts: 640
|
Posted: 08/03/2016, 3:18 PM |
|
A purely PHP solution requires a button on the same form as the listbox.
On button click, you can use an Action "Save Control Value".
Control name is the 'listbox' name
Destination Type Is: Session
And Destination Name is whatever you want to name the Session Variable example: listboxvalue
Then you run a 'custom code' update query on the grid results, same table as was used in grid builder and same MySQL arguments...
custom code example:
$db = new cls DBConnection1():
$SQL = "UPDATE gridtable SET textboxfield =" . CCGetSession("listboxvalue") . "WHERE whatever and whatever";
$db->query($SQL);
$db->close();
When the page refreshes, all the grid will show whatever value came from the listbox.
Somewhere, remember to clear the session variable CCSetSession("listboxvalue",""):
The other way involves using javascript to detect the onchangeevent of the listbox, and applying the value to to the grid - here is the onchange in jquery:
This will get the text value from the listbox:
<script>
$(document).ready(function(){
$('#the_html_ID_of yourlistboxgoeshere').change(function(){
var listboxtext = $(this).find('option:selected').text();
Alert(listboxtext);
});
});
</script>
This will get the select value from the listbox:
<script>
$(document).ready(function(){
$('#the_html_ID_of yourlistboxgoeshere').change(function(){
var listboxvalue = $(this).find('option:selected').val();
alert(listboxvalue);
});
});
</script>
I've not written a value back to multiple grid fields using Jquery JS after getting it using onchange, but I've done similar and there is a wealth of stuff to be found by googling this subject.
_________________
Central Coast, NSW, Australia.
|
|
|
|