i have a input box that is within a div.This input box is replaced by another input box onchange the select box value.now i want to post this input box value in php variable so that i can insert it into database. here is my input box before onchange select box value:
<div id="pay"><input type="text" name="cheque_no" /></div></td>
function of onchange select box is below:
function changeVal2(value)
{
var rows = document.getElementsByTagName('label');
var rows2= document.getElementById('pay');
var xx=document.getElementById('myid');
var yy=xx.innerHTML;
var txt=document.getElementById('txtbox');
var txt2=txt.innerHTML;
for(var i in rows)
{
if(rows[i].id == 'mylabel')
{
if(value=="Direct To Bank")
{
rows[i].innerHTML = "Bank Account"; //for display only a single value that is currently selected
rows2.innerHTML=yy;
document.getElementById('myid').style.display='none';
//rows[i].innerHTML += value; //for gettting all those values that are selected again and again
}
else
{
rows[i].innerHTML = "Cheque/DD No.";
rows2.innerHTML=txt2;
}
}
}
}
here is the input box that is replaced after onchange select box value:
<div id="txtbox" style=""><input type="text" name="cheque" id="cheque" /></div>
now i want to post this input box value in php variable as follows:
echo $cheque_no=$_POST['cheque'];
please give me suggestion for this problem.I have spend 3-4 hours on this problem.Thanks in advance...
If I could better understand your problem that you are trying to replace div element by onchange
on the same page, its mean the existance of that input box is twice on that page, and for post via php you have to make input element name as array like this...
<div id="txtbox" style=""><input type="text" name="cheque[]" id="cheque" /></div>
and try to post it with php as $_POST['cheque'][0]
or $_POST['cheque'][1]
.
If you are facing double existance of input box then it will definately resolve your issue...
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加