
shadd
Members-
Posts
55 -
Joined
-
Last visited
Everything posted by shadd
-
How to do math jax on whole page generated dynamically
shadd replied to shadd's topic in Javascript Help
i contacted the math jax help /support and this is how it went: OK, so this is a page constructed by PHP, and while the document is created on the fly, the actual page is static, in that the DOM isn't altered once it has arrived at the browser, correct? That is different from what I thought you meant by "dynamic content", which usually means altering the DOM on the fly within the browser. That would require using MathJax.typesetPromise(). Your situation should not. So this leads to the question of whether the math is properly inserted into the page. So when you say echo '<div>'.$Question.'</div>' what is the contents of $Question? That may be the problem. In particular, are you using $...$ or \(...\) for the math delimiters, and if the latter, are you sure the backslashes are properly in $Question? Can you view the page source (not the DOM inspector, but the page source) and verify that the math delimiters and backslashes are correct in the document? When you say "it fails", what does that mean? Does it mean that the math is not processed at all, or does it typeset, but not correctly? Davide(mathjax reply 1) My response: when i say it fails,i mean that the tex is not parsed at all and is displayed as it is in the browser. When i view the page source,i see this <div class="que_text">21. Our father <span>\</span>(<span>\</span>underline{refused}<span>\</span>) us to use the internet. </div> <div class="que_text">22. Parents should buy (underline{decent}) clothes for their children. </div> What could be th problem? I double backslashed the first question before saving to database in question 21 above,I did not save it inside a <span> ??Where did that <Span> come from?? In question 22 i only saved without double backslashes ? where am i going wrong?? reply2 n question 22, MathJax will not see any math, because there are no \(...\) delimiters (the backslashes are missing on the delimiters, as well as from the \underline macro). So that explains why you are not getting typeset math. But the question is why have the backspaced been removed? I don't see anything in your PHP code that would do that, but I'm not a PHP expert, and only scanned through it quickly. My guess is that the backslashes aren't actually being saved in the database. Either that, or whatever is setting up $this->view_data is removing them. I don't have access to the code that handles either of those, so can't tell for sure. In question 21, the <span>\</span>( will not be seen by MathJax as a math delimiter, so MathJax doesn't think there is any math in that question, either. It is possible that these spans are due to MathJax's processing of escaped characters. That is, if the original page included \\(\\underline{refused}\\), then MathJax would replace each of the three double backslashes by <span>\</span>, and that would account for the output you are seeing. But "view source" should show \\(\\underline{refused}\\), not the spans, so either this is not the view source output, but actually the DOM output, or the browser's view source option isn't showing the original HTML file, as it should be. Which browser are you using? One experiment is to include processEscapes: false, in the tex section of your MathJax configuration, and see if that changes the page source for question 21 to be \\(\\underline{refused}\\) instead, as that would tell us that the spans are from MathJax. If that's the case, then it means your question data include double backslashes instead of single backslashes. So in both cases, it looks to me like the data from the database is in error (for 21, there are too many backslashes, and for 22, not enough). So you will need to look into how the questions are stored in the database, or how the $this->view_data is populated from the database to see how backslashes are handled in your workflow. That seems to be the source of the problem. Davide(for mathjax) my response: Thanks for the explanation. it was the way that i store the tex code in the databse which was the source of the problem.I edited it direct in phpMyadmin and the tex was rendered very clearly . steven -
thanks for cleaning up
-
thanks for cleaning up
-
I have the set up below in my form. <label for="question">Sub Question <span class="req">*</span></label><textarea cols="46" rows="3" name="subquestion[]" placeholder="Enter Sub question here.."></textarea><div class="divider "></div><div class="divider"></div><textarea class="opt_text opt_text0 " cols="46" rows="2" name="choice0[]" placeholder="Enter Choice A here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img0" style="display: none;">Add Choice A Image(if any..)</label><input type="file" class="opt_img opt_img0" name="o-image0[]" style="display: none;"><br><br><textarea class="opt_text opt_text0 " cols="46" rows="2" name="choice0[]" placeholder="Enter Choice B here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img0" style="display: none;">Add Choice B Image(if any..)</label><input type="file" class="opt_img opt_img0" name="o-image0[]" style="display: none;"><br><br><textarea class="opt_text opt_text0 " cols="46" rows="2" name="choice0[]" placeholder="Enter Choice C here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img0 " style="display: none;">Add Choice C Image(if any..)</label><input type="file" class="opt_img opt_img0" name="o-image0[]" style="display: none;"> <br><br><textarea class="opt_text opt_text0 " cols="46" rows="2" name="choice0[]" placeholder="Enter Choice D here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img0" style="display: none;">Add Choice D Image(if any..)</label><input type="file" class="opt_img opt_img0" name="o-image0[]" style="display: none;"><li><label for="question">Sub Question <span class="req">*</span></label><textarea cols="46" rows="3" name="subquestion[]" placeholder="Enter Sub question here.."></textarea><div class="divider "></div><div class="divider"></div><textarea class="opt_text opt_text1 " cols="46" rows="2" name="choice1[]" placeholder="Enter Choice A here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img1" style="display: none;">Add Choice A Image(if any..)</label><input type="file" class="opt_img opt_img1" name="o-image1[]" style="display: none;"><br><br><textarea class="opt_text opt_text1 " cols="46" rows="2" name="choice1[]" placeholder="Enter Choice B here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img1" style="display: none;">Add Choice B Image(if any..)</label><input type="file" class="opt_img opt_img1" name="o-image1[]" style="display: none;"><br><br><textarea class="opt_text opt_text1 " cols="46" rows="2" name="choice1[]" placeholder="Enter Choice C here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img1 " style="display: none;">Add Choice C Image(if any..)</label><input type="file" class="opt_img opt_img1" name="o-image1[]" style="display: none;"> <br><br><textarea class="opt_text opt_text1 " cols="46" rows="2" name="choice1[]" placeholder="Enter Choice D here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img1" style="display: none;">Add Choice D Image(if any..)</label><input type="file" class="opt_img opt_img1" name="o-image1[]" style="display: none;"><li><label for="question">Sub Question <span class="req">*</span></label><textarea cols="46" rows="3" name="subquestion[]" placeholder="Enter Sub question here.."></textarea><div class="divider "></div><div class="divider"></div><textarea class="opt_text opt_text2 " cols="46" rows="2" name="choice2[]" placeholder="Enter Choice A here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img2" style="display: none;">Add Choice A Image(if any..)</label><input type="file" class="opt_img opt_img2" name="o-image2[]" style="display: none;"><br><br><textarea class="opt_text opt_text2 " cols="46" rows="2" name="choice2[]" placeholder="Enter Choice B here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img2" style="display: none;">Add Choice B Image(if any..)</label><input type="file" class="opt_img opt_img2" name="o-image2[]" style="display: none;"><br><br><textarea class="opt_text opt_text2 " cols="46" rows="2" name="choice2[]" placeholder="Enter Choice C here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img2 " style="display: none;">Add Choice C Image(if any..)</label><input type="file" class="opt_img opt_img2" name="o-image2[]" style="display: none;"> <br><br><textarea class="opt_text opt_text2 " cols="46" rows="2" name="choice2[]" placeholder="Enter Choice D here.." style="display: none;"></textarea><label for="image" class="opt_img opt_img2" style="display: none;">Add Choice D Image(if any..)</label><input type="file" class="opt_img opt_img2" name="o-image2[]" style="display: none;"></li> How can I get the data and validate that it is set in php?? each sub question can have a set of multiple choices either text or file but not both.and this is not a must.
-
How to do math jax on whole page generated dynamically
shadd replied to shadd's topic in Javascript Help
when i put the latex direct into html, it renders well as above,but when i do this: echo ' '.$Question.'</div>'; it fails. Why?? -
How to do math jax on whole page generated dynamically
shadd replied to shadd's topic in Javascript Help
All that latex code is generated dynamically from the database. i have tried this but all in vain so far <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <!-- Configuration of math jax --> <script> MathJax = { tex: { inlineMath: [['$', '$'], ['\\(', '\\)']] }, svg: { fontCache: 'global' } }; // document.addEventListener('load', function(){ // MathJax.typeset('que_text'); //}) // MathJax.Hub.Queue(["Typeset", MathJax.Hub]); // $(document).on('load',function(e){ //$(preview).html(e.target.value) //MathJax.typeset();}); /*if (window.MathJax) { node = document.getElementByClass('que_text'); MathJax.typesetPromise([node]).then(() => {}); }*/ </script> -
i have a page that display data dynamically with math/ latex got from db; how can i display the latex well for this page dynamically generated. <div class="que_text">1. how \(\underline{decent}\).ike.</div><div class="que_ans">what<div class="icon tick "><i class="fas fa-check"></i></div> </div> <footer><form id="aAns1" method="POST" action=""> <input type="hidden" name="sAction" value="addAns"> <button class="Add_ans">Add answer</button></form><form id="eAns1" method="POST" action=""> <input type="hidden" name="sAction" value="editAns"> <button class="Edit_ans">Edit answer</button></form> <form id="aQue1" method="POST" action=""> <input type="hidden" name="sAction" value="editQue"> <button class="nxt_btn Edit_que" id="Edit_que">Edit / Add to Question</button></form> </footer><div class="que_text">2. John \(\underline{refused}\) that she had stolen his friend's money.</div><div class="que_ans">say<div class="icon tick "><i class="fas fa-check"></i></div> </div> <footer><form id="aAns2" method="POST" action=""> <input type="hidden" name="sAction" value="addAns"> <button class="Add_ans">Add answer</button></form><form id="eAns2" method="POST" action=""> <input type="hidden" name="sAction" value="editAns"> <button class="Edit_ans">Edit answer</button></form> <form id="aQue2" method="POST" action=""> <input type="hidden" name="sAction" value="editQue"> <button class="nxt_btn Edit_que" id="Edit_que">Edit / Add to Question</button></form> </footer>
-
Thanks I saw a n error Fatal error: Uncaught Error: Call to undefined function cont() in D:\.....\.........\Addanswer.php:83 .So i will work on that
-
-
I have a page with many forms as: <div class="que_text">1. how ...............ike.</div><div class="que_ans">what<div class="icon tick "><i class="fas fa-check"></i></div> </div> <footer><form id="aAns1" method="POST" action=""> <input type="hidden" name="sAction" value="addAns"> <button class="Add_ans">Add answer</button></form><form id="eAns1" method="POST" action=""> <input type="hidden" name="sAction" value="editAns"> <button class="Edit_ans">Edit answer</button></form> <form id="aQue1" method="POST" action=""> <input type="hidden" name="sAction" value="editQue"> <button class="nxt_btn Edit_que" id="Edit_que">Edit / Add to Question</button></form> </footer><div class="que_text">2. John......that she had stolen his friend's money.</div><div class="que_ans">say<div class="icon tick "><i class="fas fa-check"></i></div> </div> <footer><form id="aAns2" method="POST" action=""> <input type="hidden" name="sAction" value="addAns"> <button class="Add_ans">Add answer</button></form><form id="eAns2" method="POST" action=""> <input type="hidden" name="sAction" value="editAns"> <button class="Edit_ans">Edit answer</button></form> <form id="aQue2" method="POST" action=""> <input type="hidden" name="sAction" value="editQue"> <button class="nxt_btn Edit_que" id="Edit_que">Edit / Add to Question</button></form> </footer> And i try to post to php as: $("button.Add_ans").click(function (e){ e.preventDefault(); var formData = $(this).closest('form').serialize(); // Loads the event data from the DB $.ajax({ type: "POST", url:'/Addanswer.php', data: formData, dataType: 'json', cache:false, //encode:true, success: function(response){ //console.log(JSON.stringify(response)); // Alert event data for now alert(response); }); } }); }); My problem is that when i have more than 4 questions the ajax fails to work especially after the 5th question on page. what is wrong here because i xpect to have more than 50 questions
-
what if i used prepared statement inside procedure will it affect the output in php set @Updateanswer_sql=CONCAT('UPDATE student_info SET address =', p_address,' WHERE id =', p_id); PREPARE sUpdateanswer FROM @Updateanswer_sql; EXECUTE sUpdateanswer; DEALLOCATE PREPARE sUpdateanswer; select "successful as result";
-
i have a stored procedure as : Create Procedure Update_studentinfo ( IN p_id INT, IN p_address varchar(20)) BEGIN UPDATE student_info SET address = p_address WHERE id = p_id; select "successful as result;" END // And works fine on the server mysql. how can I get the confirmation in Php $mSuccessMessage = Update_studentinfo(125, 'Shimla');
-
how can I make this work .I need to pass table name as variable and concat this query all together -- Prepare ansstatement PREPARE ansstatement FROM "CONCAT('INSERT INTO ',?,'(Ans_Id,Answer,answer_img) VALUES("',?,'","',? ,'","',?,'")' )"; -- Define query parameters SET @p1 = l_table_name; SET @p2 = inQueId;
-
I figured it out as i was seeking assistance. In the for loop is where i had to do the data display and not outside of it.That way the array is still present during the iteration. All your replies were a help thanks
-
Well it was the first thought on how to get the data together as a first working solution. But now as you go along in the display, things come up and iam forced to look of another hack around . can you assist please?
-
Could you please show me in code,because after the first itertion ,the next iteration overwrites the first, so how will array_merge() get a second argument then??
-
array(1) { ["data"]=> array(2) { [0]=> array(14) { ["Q_id"]=> string(438) "1.1.1|||1.1.2|||1.1.3|||1.1.4|||1.1.5|||1.1.6|||1.1.7|||1.1.8|||1.1.9|||1.1.10|||1.1.11|||1.1.12|||1.1.13|||1.1.14|||1.1.15|||1.1.16|||1.1.17|||1.1.18|||1.1.19|||1.1.20|||1.1.21|||1.1.22|||1.1.23|||1.1.24|||1.1.25|||1.1.26|||1.1.27|||1.1.28|||1.1.29|||1.1.30|||1.1.31|||1.1.32|||1.1.33|||1.1.34|||1.1.35|||1.1.36|||1.1.37|||1.1.38|||1.1.39|||1.1.40|||1.1.41|||1.1.42|||1.1.43|||1.1.44|||1.1.45|||1.1.46|||1.1.47|||1.1.48|||1.1.49|||1.1.50" ["QueNo"]=> NULL ["qNo"]=> string(238) "1|||2|||3|||4|||5|||6|||7|||8|||9|||10|||11|||12|||13|||14|||15|||16|||17|||18|||19|||20|||21|||22|||23|||24|||25|||26|||27|||28|||29|||30|||31|||32|||33|||34|||35|||36|||37|||38|||39|||40|||41|||42|||43|||44|||45|||46|||47|||48|||49|||50"["SECTION"]=> string(9) "SECTION A" } [1]=> array(14) { ["Q_id"]=> string(106) "1.1.51|||1.1.51.2|||1.1.51.3|||1.1.51.4|||1.1.51.5|||1.1.51.6|||1.1.51.7|||1.1.51.8|||1.1.51.9|||1.1.51.10" ["QueNo"]=> string(33) "b|||c|||d|||e|||f|||g|||h|||i|||j" ["qNo"]=> string(47) "51|||51|||51|||51|||51|||51|||51|||51|||51|||51"["SECTION"]=> string(9) "SECTION B" } } } from the above array, i need to associate values in each key to others for display. i have tried getting different field to separate array like so: for ($i = 0; $i < count($data); $i++){ $Section=$data[$i]['SECTION']); $Q_Id=explode('|||',$data[$i]['Q_id']); $QueNo=explode('|||',$data[$i]['qNo']);} First the data is overwritten in the arrays($Q_Id,$QueNo) how can i avoid that. So that on second loop data is simply added to the end of the array after exlode()
-
incase i want to remove the two how do I do that in php,so i get the original array
-
thanks ,how will i loop through now in php
-
how can i add two more variables to this array before passing it to the view: Say;Sub=>math and level=>''valley" Or how can i add two more variables to the array before passing them to view <?php $data = array ( 0 => array ( 'Q_id' => '1.1.1|||1.1.2|||1.1.3|||1.1.4|||1.1.5|||1.1.6|||1.1.7|||1.1.8|||1.1.9|||1.1.10|||1.1.11|||1.1.12|||1.1.13|||1.1.14|||1.1.15|||1.1.16|||1.1.17|||1.1.18|||1.1.19|||1.1.20|||1.1.21|||1.1.22|||1.1.23|||1.1.24|||1.1.25|||1.1.26|||1.1.27|||1.1.28|||1.1.29|||1.1.30|||1.1.31|||1.1.32|||1.1.33|||1.1.34|||1.1.35|||1.1.36|||1.1.37|||1.1.38|||1.1.39|||1.1.40|||1.1.41|||1.1.42|||1.1.43|||1.1.44|||1.1.45|||1.1.46|||1.1.47|||1.1.48|||1.1.49|||1.1.50', 'QueNo' => NULL, 'qNo' => '1|||2|||3|||4|||5|||6|||7|||8|||9|||10|||11|||12|||13|||14|||15|||16|||17|||18|||19|||20|||21|||22|||23|||24|||25|||26|||27|||28|||29|||30|||31|||32|||33|||34|||35|||36|||37|||38|||39|||40|||41|||42|||43|||44|||45|||46|||47|||48|||49|||50', 'SECTION' => 'SECTION A', ), 1 => array ( 'Q_id' => '1.1.51|||1.1.51.2|||1.1.51.3|||1.1.51.4|||1.1.51.5|||1.1.51.6|||1.1.51.7|||1.1.51.8|||1.1.51.9|||1.1.51.10', 'QueNo' => 'b|||c|||d|||e|||f|||g|||h|||i|||j', 'qNo' => '51|||51|||51|||51|||51|||51|||51|||51|||51|||51','SECTION' => 'SECTION B', ), ) ; ?>
-
how can i loop through this array in php ( 'data' => array ( 0 => array ( 'Q_id' => '1.1.1|||1.1.2|||1.1.3|||1.1.4|||1.1.5|||1.1.6|||1.1.7|||1.1.8|||1.1.9|||1.1.10|||1.1.11|||1.1.12|||1.1.13|||1.1.14|||1.1.15|||1.1.16|||1.1.17|||1.1.18|||1.1.19|||1.1.20|||1.1.21|||1.1.22|||1.1.23|||1.1.24|||1.1.25|||1.1.26|||1.1.27|||1.1.28|||1.1.29|||1.1.30|||1.1.31|||1.1.32|||1.1.33|||1.1.34|||1.1.35|||1.1.36|||1.1.37|||1.1.38|||1.1.39|||1.1.40|||1.1.41|||1.1.42|||1.1.43|||1.1.44|||1.1.45|||1.1.46|||1.1.47|||1.1.48|||1.1.49|||1.1.50', 'QueNo' => NULL, 'qNo' => '1|||2|||3|||4|||5|||6|||7|||8|||9|||10|||11|||12|||13|||14|||15|||16|||17|||18|||19|||20|||21|||22|||23|||24|||25|||26|||27|||28|||29|||30|||31|||32|||33|||34|||35|||36|||37|||38|||39|||40|||41|||42|||43|||44|||45|||46|||47|||48|||49|||50', 'SECTION' => 'SECTION A', ), 1 => array ( 'Q_id' => '1.1.51|||1.1.51.2|||1.1.51.3|||1.1.51.4|||1.1.51.5|||1.1.51.6|||1.1.51.7|||1.1.51.8|||1.1.51.9|||1.1.51.10', 'QueNo' => 'b|||c|||d|||e|||f|||g|||h|||i|||j', 'qNo' => '51|||51|||51|||51|||51|||51|||51|||51|||51|||51','SECTION' => 'SECTION B', ), ), )
-
array(1) { ["data"]=> array(2) { [0]=> array(14) { ["Q_id"]=> string(438) "1.1.1|||1.1.2|||1.1.3|||1.1.4|||1.1.5|||1.1.6|||1.1.7|||1.1.8|||1.1.9|||1.1.10|||1.1.11|||1.1.12|||1.1.13|||1.1.14|||1.1.15|||1.1.16|||1.1.17|||1.1.18|||1.1.19|||1.1.20|||1.1.21|||1.1.22|||1.1.23|||1.1.24|||1.1.25|||1.1.26|||1.1.27|||1.1.28|||1.1.29|||1.1.30|||1.1.31|||1.1.32|||1.1.33|||1.1.34|||1.1.35|||1.1.36|||1.1.37|||1.1.38|||1.1.39|||1.1.40|||1.1.41|||1.1.42|||1.1.43|||1.1.44|||1.1.45|||1.1.46|||1.1.47|||1.1.48|||1.1.49|||1.1.50" ["QueNo"]=> NULL ["qNo"]=> string(238) "1|||2|||3|||4|||5|||6|||7|||8|||9|||10|||11|||12|||13|||14|||15|||16|||17|||18|||19|||20|||21|||22|||23|||24|||25|||26|||27|||28|||29|||30|||31|||32|||33|||34|||35|||36|||37|||38|||39|||40|||41|||42|||43|||44|||45|||46|||47|||48|||49|||50"["SECTION"]=> string(9) "SECTION A" } [1]=> array(14) { ["Q_id"]=> string(106) "1.1.51|||1.1.51.2|||1.1.51.3|||1.1.51.4|||1.1.51.5|||1.1.51.6|||1.1.51.7|||1.1.51.8|||1.1.51.9|||1.1.51.10" ["QueNo"]=> string(33) "b|||c|||d|||e|||f|||g|||h|||i|||j" ["qNo"]=> string(47) "51|||51|||51|||51|||51|||51|||51|||51|||51|||51"["SECTION"]=> string(9) "SECTION B" } } } how can I loop through such an array using php
-
Thanks Admin,i had to go back and re-read php and figured out how to get the data.
-
Iam very sorry Sir. Iam writing an MVC FROM SCRATCH. When iam in the paper controller class,the variables $StudylevelId,$SubjectId,$PaperId, are available with in that scope. how can I avail them to the model class Paperview class PaperView { // Public variables to be used in fsa template public $mPaper; public $mPaperId; // Private stuff private $_mStudylevelId; private $_mSubjectId; private $_mPaperId; // Class constructor public function __construct($StudylevelId,$SubjectId,$PaperId) { // Variable initialization // Get StudylevelId if ($StudylevelId<>'') $this->_mStudylevelId = (int)$StudylevelId; // Get SubjectId from query string casting it to int if ($SubjectId<>'') $this->_mSubjectId = (int)$SubjectId; if ($PaperId<>'')//$_GET['ProductId'])) $this->mPaperId = (int)$PaperId; //$_GET['ProductId']; else trigger_error('PaperId not set'); } } which is called in the view file below: Yes i have made them public in the papercontroller class,but now how do i access them here where they are required <section class="bg" > <?php require MODEL.'paper_view.php'; // Create presentation object $Papersdetail=new PaperView($StudylevelId,$SubjectId,$PaperId); ?> <!-- Quiz Box --> <div class="quiz_box"> <header> <div class="title"><?=$Papersdetail->mPaperId?><h2></header> i hope i have tried explaining better