Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value Javascript Input

how can i transfer the Value from Input 1 in 2 and add some letters?

<script type="text/javascript">

function doit(){
document.getElementById('input2').value=document.getElementById('input1').value;
}

</script>

Input1: 2342

Input2: pcid2342d

Can some one help me?

like image 296
Sebastian Avatar asked Feb 27 '23 17:02

Sebastian


1 Answers

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

<script type="text/javascript">

function doit(){
document.getElementById('input2').value="pcid" + document.getElementById('input1').value + "d";
}

</script>
like image 161
greg0ire Avatar answered Mar 07 '23 17:03

greg0ire