My code should combine PHP / HTML / JS.
What I want to do is copy the text from the myurl
textarea
, while writing.
And save it as new $myurl
PHP
PHP/HTML:
<?php
$myurl = $_SERVER['REQUEST_URI'];
// That the new $myurl would be here before the php code closed
?>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<center>
<textarea id="myurl" class="form-control" style="color:black; background-color:#fff; resize:none;"> txt i want to save as $myurl string </textarea>
<br>
<div>
<span style="color:#fff" class="" id="test">test</span>
</span>
<input id="submit" name="submit" type="submit" class="btn btn-primary" onclick="test3();" value="Submit" disabled/>
</div>
</center>
<center><div class="test2"></div><br></center>
// The js file is not related to the subject:
<script src='index.js'></script>
</body>
</html>
UPDATE (What I tried):
<script>
$(document).ready(function(){
$('#myurl').on('change keyup paste',function(){
$("#submit").click()
});
});
</script>
<script>
function test3(){
var javavar=document.getElementById("myurl").value;
document.getElementById("myurl").innerHTML="<?php $myurl='"+javavar+"'; echo $myurl;?>";}
</script>
This should be saved as a PHP string.
But I add at the beginning of the page echo $myurl
It shows nothing.
I do not want echo
to be inside the script