1
hello, I need to take part of the input value
function exibir(){
var elem = document.getElementById("campo3").value;
var sel = document.getElementById("campo4").value;
document.getElementById("demo1").value = elem+sel;
}
<link href="https://getbootstrap.com/docs/4.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Nova pagina 1</title>
</head>
<body>
<div class="container">
<div class="panel panel-default" id="panel_dadosdasolicitacao2" >
<div class="panel-body">
<div class="row" >
<div class="form-group col-md-3">
<label> Campos 1 </label>
<input type="text" class="form-control" name="campo3" id="campo3" value="Contrato">
</div>
</div>
<div class="row">
<div class="form-group col-md-3">
<label> Campos 2 </label>
<input type="text" class="form-control" name="campo4" id="campo4" value="Empresa">
</div>
</div>
<div class="row">
<div class="form-group col-md-3">
<label> Junção </label>
<input type="text" class="form-control" name="demo" id="demo1" readonly>
</div>
</div>
<div class="row">
<div class="form-group col-md-3">
<label> Resultado esperado </label>
<input type="text" class="form-control" name="demo" id="demo2" value="ConEmp">
</div>
</div>
<div class="form-group col-md-3">
<button class="btn btn-dark" onclick="exibir()" id="clicar">Gerar</button>
</div>
</div>
</div>
</div>
</body>
</html>
In this example he copies the two values I kind of wanted it like this:
a field that appears [Contratoempresa] present in the field only the first 3 values of the field. example Result: [Contratoempresa] turn up [Conemp]
Correct there,, the junction should be
ContratoEmpresa
in the element ofid=campo3
andConEmp
in the element ofid=campo4
– user60252
I don’t understand @Leocaracciolo. These fields are the inputs of the names
Contrato
andEmpresa
, respectively, no? What I understood is that the user wanted the result in the fielddemo1
was the same as that ofdemo2
. However, regardless of this ambiguity the end result is the same.– bio
In its expected result what appears is the existing value and it wants the substring result
– user60252
I think the posted image confused everything. In the code there are the two inputs
– user60252
Ah!! Now it’s gone! : ) but as I said, the learning was the same.
– bio