CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 PHP variables in Javascript on the HTML page

Print topic Send  topic

Author Message
hgromek

Posts: 5
Posted: 08/17/2017, 1:04 PM Quote message

Hi, please excuse my novice on these subjects, I am just learning as I go.

Can you please help me with executing Javascript that is in my html file but needs to use php variables I created in a before show custom code.

I have sifted through a lot of these topics on the forums, and it just makes my head spin!

I started in a php file testing file and when I need to convert for codecharge use I can't find the way to replace

var number = '"<?php echo $number; ?>";

as this doesn't retrieve any information for me. :-(

Any advice is greatly appreciated and needed!
_________________
Hal
View profile  Send private message
mans

Posts: 7
Posted: 08/17/2017, 1:49 PM Quote message

if I understand your question
use the following statement (there is no need for the quotations):

var number = <?php echo (double) $number; ?>;


regards,
View profile  Send private message
hgromek

Posts: 5
Posted: 08/17/2017, 2:44 PM Quote message

Sorry that did not work -- it did not let the javascript run, it failed at the Edit Button.

here is the javascript I am running in the html page of CodeChargeStudio - it runs correctly when I place static text instead of the php variables.

<script type="text/javascript">   
$(document).ready(function(){   
$('#edit_button').click(function(){   
    
var setdata = "<?php echo trim(preg_replace('/\s\s+/', ' ', $notes)); ?>";   
  
$('#editor1').val(setdata); $('#submit_button').css('display','block');   
$('#edit_button').css('display','none');   
CKEDITOR.plugins.addExternal( 'abbr', '../../ckeditor/plugins/font', 'plugin.js' );  
CKEDITOR.replace( 'editor1' ,{ extraPlugins: 'font' });  
  
 var prin_number ="<?php echo $select_value; ?>";   
$("#submit_button").click(function(e) {   
e.preventDefault();   
var editorData= CKEDITOR.instances['editor1'].getData();   
$.ajax({ type: "POST",   
url: "process_wiki.php",   
data: { editorData:editorData,prin_number:prin_number },   
success: function (res) { location.reload(); } }); }); }); }); </script>

_________________
Hal
View profile  Send private message
saseow

Posts: 699
Posted: 08/17/2017, 11:02 PM Quote message

Place a cookie with PHP and read it with javascript or add a URL parameter with PHP and get it with javascript.
View profile  Send private message
hgromek

Posts: 5
Posted: 08/18/2017, 7:01 AM Quote message

Thank you for the cookies idea! it now updates the system as it should!

Once last question - I want to display the cookie with the HTML markups however it just displays as a stored text.
like below -

%3Cp%3E%3Cb%3Eshould%C2%A0display%C2%A0like%3C%2Fb%3E%3C%2Fp%3E+%3Cul%3E+%3Cli%3E%3Cb%3Ethis%C2%A0%3C%2Fb%3E%3C%2Fli%3E%0A%3C%2Ful%3E

stored with this mark up.

<p><b>should display like</b></p>

<ul>
<li><b>this </b></li>
</ul>

thank you again,
_________________
Hal
View profile  Send private message
saseow

Posts: 699
Posted: 08/19/2017, 10:17 PM Quote message

Use str.replace in javascript.
View profile  Send private message
hgromek

Posts: 5
Posted: 08/21/2017, 6:06 AM Quote message

Worked, thank you! :-D
_________________
Hal
View profile  Send private message
hgromek

Posts: 5
Posted: 08/21/2017, 6:06 AM Quote message

Worked, thank you! :-D
_________________
Hal
View profile  Send private message

Add new topic Reply to topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.