2

I am trying to rotate all alphabets, number and symbols in 180 degree, simply I mean rotating text upside down. But the code is not working, what I am trying to do is possible with this code?

Note: I want to rotate the text written inside TextArea not want to rotate the TextArea.

JsFiddle

Code:

<!DOCTYPE html>
<html>
<body>

<form>
<textarea  id="textArea1" style="height: 100px; width: 468px;"></textarea><br />
<br />
<input onclick="myFunction()" type="button" value="Flip Text" /><br />
<br />

<textarea id="textArea2" style="height: 100px; width: 468px;"></textarea>
 
</form>

<script>
function myFunction() {

  document.getElementById("textArea2").value =  document.getElementById("textArea1").css('transform', 'rotate(180deg)');
  
}
</script>

</body>
</html>
santosh
  • 742
  • 8
  • 19
  • is this solution helps you? https://stackoverflow.com/questions/5406368/can-you-use-css-to-mirror-flip-text – Azad Jul 27 '20 at 06:22
  • Azad thanks, but my code will not work in this case? – santosh Jul 27 '20 at 06:28
  • 2
    Do you want each individual character rotated 180 ? Each line rotated 180? Or the whole text are rotated 180? – Jon P Jul 27 '20 at 06:42
  • @Jon P I want whole text or para should be rotate, whatever is written! – santosh Jul 27 '20 at 06:43
  • You should update your question to make it clear what you are trying to do. You are not getting the answers you want because the questions isn't clear. People think you want to rotate the textarea itself and you also didn't say that it must happen when a button is clicked. It might help to read [**how do I ask a good question**](https://stackoverflow.com/help/how-to-ask). – FluffyKitten Jul 27 '20 at 07:00
  • 2
    Check out this link: https://twiki.org/cgi-bin/view/Blog/BlogEntry201110x2 – Keutelvocht Jul 27 '20 at 07:11
  • 1
    Same as Twiki: https://jsfiddle.net/pw1us2zk/ – Mohan Rajput Jul 27 '20 at 07:51

3 Answers3

0

Change your function content from

document.getElementById("textArea2").value =  document.getElementById("textArea1").css('transform', 'rotate(180deg)');

to

document.getElementById("textArea1").style.transform  = 'rotate(180deg)';
dako
  • 1,081
  • 1
  • 12
  • 22
0

within youe textarea style=""add transform property as

<textarea  id="textArea1" style="height: 100px; width: 468px; transform: rotate(180deg)"></textarea><br />

you asked on button click you have to rotate so under clickFunction you have add a line as:

clickFunction(){
   document.getElementById('textArea1').style.transform = 'rotate(180deg)';
}
Sunny
  • 577
  • 6
  • 20
0

function myFunction() {

  document.getElementById('rotatedText').innerText = document.getElementById("inputArea").value;
}
#rotatedText {
  width: 468px;
  border: 1px solid #000;
  margin-top: 5px;
  
  -moz-transform: scale(1, -1);
  -webkit-transform: scale(1, -1);
  -o-transform: scale(1, -1);
  -ms-transform: scale(1, -1);
  transform: scale(1, -1);
}
<!DOCTYPE html>
<html>

<body>
  <form>
    <textarea id="inputArea" style="height: 100px; width:   468px;">I AM READY TO FLIP.</textarea>
    <br/>
    <input onclick="myFunction()" type="button" value="Flip Text" />
    <br />
    <div id="rotatedText" contenteditable="true"> </div>
  </form>

</body>

</html>