- Joined
- Dec 31, 2022
- Messages
- 12
- Reaction score
- 1
Hi, with the below userscript on a (protected) webpage I'm trying to set a text in a field when it is clicked:
but the script works in part: the text is correctly set but when I re-click in the field the value is cleared, though I wish the text was not deleted. This is the original code of the field in the webpage:
Thanks!
JavaScript:
document.getElementById("titoDs").onclick = function() {myFunction()};
function myFunction() {
document.getElementById("titoDs").value = "my text";
}
but the script works in part: the text is correctly set but when I re-click in the field the value is cleared, though I wish the text was not deleted. This is the original code of the field in the webpage:
JavaScript:
<div class="grid-row">
<!-- Ricerca per titolo e clet -->
<label id="lbl_d_datiric_titolo">
Titolo
<input type="text" name="ds" id="titoDs" class="grid-15" value="" maxlength="50">
<select name="dsCombo" id="iddsCombo" style="min-width: 0px; display: none;">
<option value="1" selected="">Parte iniziale</option><option value="2">Titolo esatto</option><option value="3">Parole (solo per ricerca in polo)</option></select><div class="chosen-container chosen-container-single chosen-container-single-nosearch" style="width: 254px;" title="" id="iddsCombo_chosen"><a class="chosen-single" tabindex="-1"><span>Parte iniziale</span><div></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" readonly=""></div><ul class="chosen-results"></ul></div></div>
</label>
</div>
Thanks!