2016-11-03 2 views
-5

어떻게 사용자 입력을 가져 와서 다른 텍스트 필드 입력으로 인쇄 할 수 있습니까? PHP를 사용하고 있습니다. 두 가지 입력 유형의 텍스트와 하나의 제출 버튼이 있습니다. 입력 A의 결과를 입력 텍스트 상자에 인쇄 할 수있게하려고합니다. 예 : <form> <input type="text" name="input"/> <!-- thiss is where the user enters text --> <input type="text" name="output"/> <!-- I take that text out and output it here --> <input type="submit" value="submit" <?php echo $input;/> </form> 출력에 "$ input"을 계속 출력하려고하지만 계속 작동하지 않습니다.사용자가 php를 사용하여 입력 필드에 입력

+0

당신이하는 것을 보여주세요. –

+0

은 항상 코드를 붙여 넣습니다. –

+0

을 입력하면 다른 텍스트 필드에 표시됩니다. js 또는 각도와 같은 프레임 워크를 사용하는 것보다 –

답변

0

PHP는 서버 측 언어이기 때문에 PHP로이를 수행 할 수 없습니다. 클라이언트 측 조작을 지원하지 않습니다.

다음과 같은 것이 필요할 것입니다.

<script type="text/javascript"> 
$(document).ready(function() { 
    $(document).on('change', 'input[name="input"]', function() { 
     var contents = $(this).val(); 
     $('input[name="outut"]').val(contents); 
    }) 
}); 
</script> 

<!-- HTML --> 
<form method="post"> 
    <input type="text" name="input" /> 
    <input type="text" name="output" value="" /> 
    <input type="submit" name="submit" value="submit"> 
</form> 

jQuery를에 대한 자세한 내용이 도움이 될 this W3Schools article

0

희망을 살펴 들어

<?php 
$output= (isset($_POST['submit']))?$_POST['input']:''; 
?> 
pure php. <br> 
try to input value in input field then submit. 
<form method="post"> 
     <input type="text" name="input"/> <!-- thiss is where the user enters text --> 
     <input type="text" name="output" value="<?php echo $output;?>"/> <!-- I take that text out and output it here --> 

    <input type="submit" name="submit" value="submit"> 
</form> 


using javascript onchange.<br>try to input value in field input1 
<form method="post"> 
     <input type="text" id="input1" name="input1" onchange="clone();"/> <!-- thiss is where the user enters text --> 
     <input type="text" id="output1" name="output1" /> <!-- I take that text out and output it here --> 

    <input type="submit" name="submit1" value="submit"> 
</form> 

<script> 
function clone() 
{ 
    var x = document.getElementById("input1").value; document.getElementById("output1").value=x; 
} 
</script> 
0

당신이 간단한 자바 스크립트 이벤트

function myFunction(){ 
 
var a=document.getElementById('a').value; 
 
\t document.getElementById('b').value= a 
 
\t }
<form> 
 
     <input type="text" name="input" \t onkeydown="myFunction()" onkeydown="myFunction()" id="a"/> <!-- thiss is where the user enters text --> 
 
     <input type="text" name="output" id ="b"/> <!-- I take that text out and output it here --> 
 
     <input type="submit" value="submit" > 
 
    </form>
을 사용하여 찾고있는 것을이 될 수 있습니다

관련 문제