J’essaie la fonction do JavaScript pour remplir un champ de formulaire. Ça marche s’il n’y a pas de retour à la ligne dans le texte, mais dès que je crée une chaîne de caractères avec ‘return’ ou ‘linefeed’ ou ‘\n’ ça ne marche plus? Une idée?
This is what I got as an English translation for your question. I hope it’s close enough. I’m afraid that you’ll have to get my post translated some way or another.
I’m trying the JavaScript function to fill in a form field. It works if there is no line feed in the text, but as soon as I create a string with ‘return’ or ‘linefeed’ or ‘\n’ it doesn’t work anymore
I don’t think that a form input field will necessarily be able to accept linefeeds. Some will filter them out. You don’t provide the page/form/field in question so I can’t test it.
But here is something I would try first. To insert a ‘linefeed’, type control-option-j. For ‘return’, type control-option-m. You can try these key combinations out in textedit to confirm that they work in a general environment. I don’t typically want to enter linefeeds in an input field but sometimes I want to enter a tab (control-option-i) and this usally works.
I don’t think any settings require changing for them to work but I’ve forgotten where I learned of them. Hope this helps.
This is a textarea that I’m trying to fill.
But as soon as I insert a return statement, it stops working:
set myData to "Line 1 " & return & “Line 2”
or
set myData to "Line 1 & linefeed & “Line 2”
or
set myData to “Line 1
Line 2”
or
set myData to “Line 1 ¬
Line 2”
whereas
set myData to “Line 1 - Line 2” works.
set cmd to “document.forms[0].elements[‘texte’].value='” & myData & “'”
do JavaScript cmd