function doit(){ document...">

Javascript Login Value

how can i pass the value from input 1 to 2 and add some letters?

<script type="text/javascript"> function doit(){ document.getElementById('input2').value=document.getElementById('input1').value; } </script> 

Entrance 1: 2342

Input2: pcid2342d

Can someone help me?

+4
source share
4 answers

Just use the + operator to add a line before and after the input value.

 <script type="text/javascript"> function doit(){ document.getElementById('input2').value="pcid" + document.getElementById('input1').value + "d"; } </script> 
+7
source

String concatenation:

 document.getElementById('input2').value = "stuff" + document.getElementById('input1').value + "other stuff"; 

When working with numbers, you can start by concatenating with an empty string, so as not to add numbers together, and not to concatenate strings (due to the order in which the operator is evaluated):

 document.getElementById('input2').value = "" + 1234 + 567 + document.getElementById('input1').value + 89; 
+1
source

Well, it looks like you have already done the work, you just need to click to complete it:

 <button onclick="doit()">click me</button> 
0
source

Why don't you try something in jQuery?

  $("#Anything").click(function() { $("#Field1").val($("#Field2").val()); }); 

"click" is just a guess =)

0
source

Source: https://habr.com/ru/post/1314434/


All Articles