Coder Social home page Coder Social logo

lesstocsssystem's People

Contributors

s1042992 avatar

Stargazers

 avatar

Watchers

 avatar

lesstocsssystem's Issues

Codemirror can't use through my ajax !Help!!

The problem is that the textarea can't show the style of CodeMirror through the ajax.

At html, I have a

to show the content of another php file,
And my <textarea> have to be in php file, because the textarea content is from my database, and the code is written in the php file.
here's the a part of my code at HTML

<div id="txtHint"></div> //where i want to show the php content on 

<script> 			
	function showLess() //AJAX  ,do it when <select>'s value changed
	{
	        var str = document.getElementById("category").value;  //value of <select>
		var str_v = document.getElementById("version_select").value; //value of <select>
		if (str==""||str_v=="")
		{
			document.getElementById("txtHint").innerHTML="";
			return;
		} 
		if (window.XMLHttpRequest)
		{
		// IE7+, Firefox, Chrome, Opera, Safari 
			xmlhttp=new XMLHttpRequest();
		}
		else
		{				
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
		
			}
		}
		var params = 'q=' +str+'&v='+str_v;
							
		xmlhttp.open("POST","getless_mysql.php",true);
							
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send(params);		
	}
        function HightLight()
        {
                var editableCodeMirror = CodeMirror.fromTextArea(document.getElementById('LessText'), {
                mode: "javascript",
                theme: "default",
                lineNumbers: true
                });
        }
        HightLight();

</script>

And this is a part of my php code:

<?php
echo '<form method="post" action="update_less.php">';
echo '<textarea   rows="10"  id="LessText" name="LessText">';
if($q==1) //q is the value form <select>
{
	echo htmlspecialchars_decode($row['less_carousel']);
}
	
else if($q==2)
{
	echo htmlspecialchars_decode($row['less_alerts']);
}
echo '</textarea>';
echo '<br>';
echo '<input class="special" type="submit" value="Update"/>';
echo '</form>';
?>

The whole flow of my concept is :


1. In HTML: get the <select> values and send them to php file.

2. In PHP: get the data from database and echo  tag <textarea> and its value which is the data we just got from database in the php file.

3. Because of "document.getElementById("txtHint").innerHTML=xmlhttp.responseText" , txtHint will store all the content which is echoed in PHP file.

4. Show the <div  id="txtHint"> on HTTP.

I'm wondering why my Codemirror isnt work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.