TOPIC:

how to use a php variable inside js script 3 days 3 hours ago #254580

  • Topic Author
  • ferrari
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 16
  • Thanks: 0
Hi all,
guys i have this problem: i have to use a php script (piece) for 2 things

1- i have to recover soome datas from my db with a sql query 8select).;
2- then i have to use these data inside a javascript code (the js code is inside the php script)
[code]
  
$data="2021-3-21";
echo '<script type="text/javascript">
		JQuery(document).ready(function () {
			
                       
                       		
			JQuery("#ff_elem180_calendarButton").pickadate({
				format: "yyyy-mm-dd", 
				selectYears: 60, 
				disable:  $data ,
				selectMonths: true,
				editable: true,
				firstDay: 1,
				onSet: function() {JQuery("#ff_elem180").val(this.get("value"));}
			});
                    });
	</script>';
[/code]

someone can help me solving this issue?

Please Log in or Create an account to join the conversation.

how to use a php variable inside js script 3 days 3 hours ago #254581

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 3734
  • Karma: 3
  • Thanks: 302
HI,

please try this:
$data="2021-3-21";
echo '<script type="text/javascript">
		JQuery(document).ready(function () {
			
                       
                       		
			JQuery("#ff_elem180_calendarButton").pickadate({
				format: "yyyy-mm-dd", 
				selectYears: 60, 
				disable:  ['.$data.'],
				selectMonths: true,
				editable: true,
				firstDay: 1,
				onSet: function() {JQuery("#ff_elem180").val(this.get("value"));}
			});
                    });
	</script>';

Let me know the result

Regards,
Tihana

Please Log in or Create an account to join the conversation.

how to use a php variable inside js script 3 days 3 hours ago #254583

  • Topic Author
  • ferrari
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 16
  • Thanks: 0
Hi thanks for the reply, can i ask you something else?
How can i use the response data from a sql select?
i need to use multiple data from a select

[code][code]
   
   $data="SELECT `dataApp`FROM `cons_appuntamenti`;";
    $sql=mysqli_query($connection, $data) or die(mysqli_error($connection));
   //here i have to use the data response from the select
[/code][/code]

Please Log in or Create an account to join the conversation.

how to use a php variable inside js script 3 days 3 hours ago #254584

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 3734
  • Karma: 3
  • Thanks: 302
Hi,

like this:
$db = JFactory::getDBO();
$sql = "SELECT `dataApp`FROM `cons_appuntamenti` ";
$db->setQuery($sql);
$data = $db->loadObjectList();

echo '<script type="text/javascript">
		JQuery(document).ready(function () {
			
                       
                       		
			JQuery("#ff_elem180_calendarButton").pickadate({
				format: "yyyy-mm-dd", 
				selectYears: 60, 
				disable:  ['.$data.'],
				selectMonths: true,
				editable: true,
				firstDay: 1,
				onSet: function() {JQuery("#ff_elem180").val(this.get("value"));}
			});
                    });
	</script>';

Regards,
Tihana

Please Log in or Create an account to join the conversation.

how to use a php variable inside js script 2 days 23 hours ago #254619

  • Topic Author
  • ferrari
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 16
  • Thanks: 0
thanks man,
can i ask you the last thing?
i need to recover inside the javascript code a php array.
   //include ('libraries/libOtp/db_conn.php');
$db = JFactory::getDBO();
$sql = "SELECT `dataApp`FROM `cons_appuntamenti` ";
$db->setQuery($sql);
$data = $db->loadObjectList();
$dataArray=array();
for ($i = 0; $i <count($data); $i++) {
  $dataArray[$i]=$data[$i]->dataApp;
  // array_push($dataArray, data[$i]->dataApp);
    //$dataArray.push($data[$i]->dataApp);
   //echo $dataArray[$i];
};

$dataArray1=changeFormat($dataArray);
var_dump($dataArray1);

//$data="SELECT `dataApp`FROM `cons_appuntamenti`;";
 //$sql=mysqli_query($connection, $data) or die(mysqli_error($connection));
//var_dump( $dataArray);
echo '<br>';
echo '<script type="text/javascript">
		JQuery(document).ready(function () {
                            
                            var arrData='.$dataArray1.';
	                    var testData = [new Date(2021, 0, 22), new Date(2021,0,23)]; 		
			JQuery("#ff_elem180_calendarButton").pickadate({
				format: "yyyy-mm-dd", 
				selectYears: 60,
                                disable: testData,
				selectMonths: true,
				editable: true,
				firstDay: 1,
				onSet: function() {JQuery("#ff_elem180").val(this.get("value"));}
			});
                    });
	</script>';
            

   


line 24 i need to recover the array variable from php.

Please Log in or Create an account to join the conversation.

how to use a php variable inside js script 2 days 23 hours ago #254621

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 3734
  • Karma: 3
  • Thanks: 302
Hi,

where did you want to show this?
Inside disable or?

Regards,
Tihana

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Time to create page: 0.051 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!