2つのテキストフィールドがあり、最初のテキストフィールドにユーザーが入力すると、Ajaxによって2番目のテキストフィールドに表示されます。forループを使用して複数の行を作成する必要があり、すべての行に独自の値があります。 HTML
<form style="text-align:center" method="post" action="" name="form1">
<?php for($x=0; $x<4; $x++){ ?>
<input type="text" size="30" id="country" onChange="getCurrencyCode('find_ccode.php?country='+this.value)" />
<input type="text" name="cur_code" id="cur_code" ></p>
アヤックス
function getXMLHTTP() {
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getCurrencyCode(strURL)
{
var req = getXMLHTTP();
if (req)
{
req.onreadystatechange = function()
{
if (req.readyState == 4)
{
if (req.status == 200)
{
document.getElementById('cur_code').value=req.responseText;
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
PHP
$country=$_REQUEST['country'];
echo $country;
手伝ってください。