Forums

Dynamic dropdown problem when double quote (") is present

rotocal 20 Apr, 2020
Dynamic dropdown field is reading data from a database table (MySql). The field in consideration reads Item descriptions of hardware. When I select items with a " (double quote), like - Screw black 1" - or - Screw black 2-1/2" - or - Screw 2 1/2" (Black) - I can see the result in the selection field, and it is OK see please screenshot below. However, when I try to run an Ajax request to PHP in order to read the database (based on description) and bring back the remaining data for this form, the description can not be read because the quote, and nothing pass to the ajax request to PHP. The other descriptions (without the double quote) work perfectly . How can I solve this issue please.
Even after submission of the form trying to assing the value to $description = $this->data['Description'] ; doesn't work when a double quote is present. Tried also with mysql REPLACE (Description, '"', '\"') when reading the dynamic data. Thank you




Part of the event and ajax call ... (event can be simple javascript as well addEvent Listener)

$('#descripcionpop').change(function(){
var selBox = $('#descripcionpop').find(":selected").html();
console.log('Selected text value is ',selBox);
selBox = $('#descripcionpop').find(":selected").val();
console.log('Selected actual value is ',selBox);


alert("In event.....!! - " + selBox);


$.ajax({
url : '/includes/descrip-popup.php',
type: "POST",
data : {descripcion : selBox},
success: function(response,status,xhr)
{ .................
Max_admin 22 Apr, 2020
I'm not sure but the double quotes are in the options values and text or only text ? if they are in the values then please check the page source, do they break the options code ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
rotocal 23 Apr, 2020
Yes they are in the values and brake the code producing a undefine value to be pass to the ajax request. The thing is ... that people creating new items could write this 2-1/4" instead of 2-1/4 inch all the time, .....something I can not control. Thanks
Max_admin 23 Apr, 2020
Did you check the page source ? does it break the value attribute ? if yes then you will need to convert quote to special chaarcters using PHP first!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.