04-21-2016, 01:32 PM
You didn't describe the value of the $js variable, but in general, jQuery can handle elements by their id or class.
It should work if you do this:
It should work if you do this:
PHP Code:
<?php echo form_input(array('id' => 'input1', 'name' => 'name', 'class' => 'form-control')); ?>
<?php echo form_input(array('id' => 'input2', 'name' => 'url', 'class' => 'form-control')); ?>
<script>
$(document).ready(function() {
$('#input1').keyup(function() {
var text = $('#input1').val();
$('#input2').val(text);
});
});
</script>