ARTICLE AD BOX
I have a operation logic to do in two simples steps into a input value. For me it's like a input cleaning operation I would love to do.
Inside of my input I have some blocks of numbers, for instance: 548 601 **002** 847 147
Then what I need:
Firstly, after the bloc of numbers selected 002 at the left side. Jump the blank space and the block of numbers just after 847, Then remove all the rest of numbers.
Secondly, after that be removed. At the final step remove the block of numbers selected include all the rest of blocks of numbers.
All these operations are excecuted into one button.
Attention: These numbers 548 601 002 847 147 are just an example to help you to understand what I would love to do.
<?php $initialValue = $_POST['phpInput']; $searchTermPHP = "002"; ?> <input type="text" id="phpInput" style="width:100em" value="<?php echo htmlspecialchars($initialValue); ?>"> <button onclick="findAndSelectPHP('<?php echo htmlspecialchars($searchTermPHP); ?>')"> Select "<?php echo htmlspecialchars($searchTermPHP); ?>" </button> <script> function findAndSelectPHP(searchTerm) { const inputElement = document.getElementById("phpInput"); const inputValue = inputElement.value; const startIndex = inputValue.indexOf(searchTerm); if (startIndex !== -1) { const endIndex = startIndex + searchTerm.length; inputElement.focus(); inputElement.setSelectionRange(startIndex, endIndex); } } </script>