hgromek
Posts: 17
|
Posted: 08/17/2017, 1:04 PM |
|
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 |
|
|
mans
Posts: 7
|
Posted: 08/17/2017, 1:49 PM |
|
if I understand your question
use the following statement (there is no need for the quotations):
var number = <?php echo (double) $number; ?>;
regards,
|
|
|
hgromek
Posts: 17
|
Posted: 08/17/2017, 2:44 PM |
|
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 |
|
|
saseow
Posts: 744
|
Posted: 08/17/2017, 11:02 PM |
|
Place a cookie with PHP and read it with javascript or add a URL parameter with PHP and get it with javascript.
|
|
|
hgromek
Posts: 17
|
Posted: 08/18/2017, 7:01 AM |
|
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 |
|
|
saseow
Posts: 744
|
Posted: 08/19/2017, 10:17 PM |
|
Use str.replace in javascript.
|
|
|
hgromek
Posts: 17
|
Posted: 08/21/2017, 6:06 AM |
|
Worked, thank you!
_________________
Hal |
|
|
hgromek
Posts: 17
|
Posted: 08/21/2017, 6:06 AM |
|
Worked, thank you!
_________________
Hal |
|
|
|