Stef
Stef

Reputation: 139

passing value inputs from one to another with a text jquery

I would like to insert a number (example 1111) and after submitting get the output (command) like "access userid 1111 instance mbb" The problem which i have is that the number should be into the text and also how to set the text properly.

See picture below:

enter image description here

This is what i have right now but not working as wished:

HTML:

  <label for="number">number:</label>
  <input type="text" name="number" id="number" />
  <input type="submit" value="Submit">

  <label for="output">output</label>
  <input type="text" size="33px"  name="output" id="output" />

JQuery:

   $('#number').change(function() {
      $('#output').val($(this).val());
    });

Thank you so much for your support

Upvotes: 0

Views: 2226

Answers (1)

SomeRSGuy
SomeRSGuy

Reputation: 600

Hope it helps.

$('#submit').click(function(){
  var source = $('#source').val();
  $('#target').val('Your val: ' + source + '. Enjoy :)');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="source">
<button type="submit" id="submit">Go</button>

<p>
<input type="text" id="target">
</p>

Upvotes: 1

Related Questions