0

I have created a script to create ad hoc Jitsi meeting rooms in PHP.

The code below almost does what I want:

  1. Create a random Jitsi meeting ID
  2. When the user clicks "Copy meeting info" this ID is copied to my clipboard.
  3. It can then be inserted in any calendar invitation by using Ctrl+V.

However I am not able to figure out how to add a line break to the my info.

The code below results in :

This event is has a video call\r\nJoin here: https://meet.jit.si/acme111186700560c1f5750c38c

I have also tried PHP_EOL instead of '\r\n' but it still does not work.

Additional information:

My problem could also be described like this:

Is it possible to modify this code to add multiple lines of text to the clipboard instead of just one line of text.

This is the code I have now:

<?php 
$meeting =  "https://meet.jit.si/acme" . rand() . uniqid(); 
?>
<div>
Your meeting room:<br><br>
</div>
<!-- The text field -->
<input type="text" value="<?php echo 'This event is has a video call' . '\r\n' . 'Join here: ' . $meeting;?>" id="myInput">
<br><br>
<!-- The button used to copy the text -->
<button onclick="myFunction()">Copy meeting room info</button>
user2298034
  • 103
  • 1
  • 8
  • 2
    `` is intended to only be used with singleline strings. Are you looking for a ` – Ian H. Jun 10 '21 at 11:32

1 Answers1

1

Good Day,

Please try this. What I changed was:

  1. The single quotes '' to double quotes "",

  2. I made the input element a textArea to be able to see if the \n\r is doing what it is suppose to do, but the main issue I had was because of the quotes. Not sure why you want to add line breaks into an input element.

  3. I tested this code here: playground

  4. You can Copy text from a textArea component too, it does not have to be a input text field.

     <?php 
     $meeting =  "https://meet.jit.si/acme" . rand() . uniqid(); 
     ?>
     <div>
     Your meeting room:<br><br>
     </div>
     <!-- The text field -->
     <textArea id="myInput"><?php echo "This event is has a 
     video call" . 
     "\r\n" . "Join here: " . $meeting;?></textArea>
     <br><br>
     <!-- The button used to copy the text -->
     <button onclick="myFunction()">Copy meeting room info</button>
    

Here is a reference to a similar issue: Copy with line breaks

Mini-Man
  • 140
  • 7