whspider
asked on
how to change text box values
Hi,
am having a text box i want to load values to another text box eachtime the valueon the first text box changes.....its only changing after i change the text and click on the text box or press enter key...
but when i use select box its changing automatically am gettin prob with text box pls help....
am having a text box i want to load values to another text box eachtime the valueon the first text box changes.....its only changing after i change the text and click on the text box or press enter key...
but when i use select box its changing automatically am gettin prob with text box pls help....
use onTextChanged Event of the textbox,Write a javascript in onTextChanged event of textbox1
ASKER
this is my code....
<script type="text/javascript">
$(document).ready(function () {
$("input[@name='test1']"). change(fun ction()
{
if ($("input[@name='test1']:c hecked").v al()=="0")
$("#cse_search").autocompl ete(search data2);
else if ($("input[@name='test1']:c hecked").v al()=="1")
$("#cse_search").autocompl ete(search data1);
}
);
});
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.X MLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLH TTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getCurrencyCode(strURL1)
{
var req1 = getXMLHTTP();
if (req1)
{
//function to be called when state is changed
req1.onreadystatechange = function()
{
//when state is completed i.e 4
if (req1.readyState == 4)
{
// only if http status is "OK"
if (req1.status == 200)
{
document.getElementById('c ur_code'). value=req1 .responseT ext;
}
else
{
alert("There was a problem while using XMLHTTP:\n" + req1.statusText);
}
}
}
req1.open("GET", strURL1, true);
req1.send(null);
}
}
</script>
<td colspan="9"><input type="text" id="cse_search" name="q" size="31" onblur="getCurrencyCode('c ode.php?lo cal='+this .value)" /></td>
</tr>
<tr>
<td>Amt: <input type="text" name="cur_code" size="7" id="cur_code" ></td>
<script type="text/javascript">
$(document).ready(function
$("input[@name='test1']").
{
if ($("input[@name='test1']:c
$("#cse_search").autocompl
else if ($("input[@name='test1']:c
$("#cse_search").autocompl
}
);
});
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.X
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLH
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getCurrencyCode(strURL1)
{
var req1 = getXMLHTTP();
if (req1)
{
//function to be called when state is changed
req1.onreadystatechange = function()
{
//when state is completed i.e 4
if (req1.readyState == 4)
{
// only if http status is "OK"
if (req1.status == 200)
{
document.getElementById('c
}
else
{
alert("There was a problem while using XMLHTTP:\n" + req1.statusText);
}
}
}
req1.open("GET", strURL1, true);
req1.send(null);
}
}
</script>
<td colspan="9"><input type="text" id="cse_search" name="q" size="31" onblur="getCurrencyCode('c
</tr>
<tr>
<td>Amt: <input type="text" name="cur_code" size="7" id="cur_code" ></td>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes this is what...but when i use mouse its not working i want using mouse click also and key also
<script type="text/javascript">
$(document).ready(function () {
$("input[@name='test1']"). change(fun ction()
{
if ($("input[@name='test1']:c hecked").v al()=="0")
$("#cse_search").autocompl ete(search data2);
else if ($("input[@name='test1']:c hecked").v al()=="1")
$("#cse_search").autocompl ete(search data1);
}
);
});
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.X MLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLH TTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getCurrencyCode(strURL1)
{
var req1 = getXMLHTTP();
if (req1)
{
//function to be called when state is changed
req1.onreadystatechange = function()
{
//when state is completed i.e 4
if (req1.readyState == 4)
{
// only if http status is "OK"
if (req1.status == 200)
{
document.getElementById('c ur_code'). value=req1 .responseT ext;
}
else
{
alert("There was a problem while using XMLHTTP:\n" + req1.statusText);
}
}
}
req1.open("GET", strURL1, true);
req1.send(null);
}
}
function populateAmount ()
{
var txtboxamt=document.getElem entById('c ur_code')
var txt1=document.getElementBy Id('cse_se arch')
//alert(txt1);
txtboxamt.value=txt1.value
}
</script>
<td colspan="9"><input type="text" id="cse_search" name="q" size="31" OnKeyup="populateAmount(); " onblur="getCurrencyCode('c ode.php?lo cal='+this .value)" /></td>
</tr>
<tr>
<td>Amt: <input type="text" name="cur_code" size="7" id="cur_code" ></td>
$(document).ready(function
$("input[@name='test1']").
{
if ($("input[@name='test1']:c
$("#cse_search").autocompl
else if ($("input[@name='test1']:c
$("#cse_search").autocompl
}
);
});
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.X
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLH
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getCurrencyCode(strURL1)
{
var req1 = getXMLHTTP();
if (req1)
{
//function to be called when state is changed
req1.onreadystatechange = function()
{
//when state is completed i.e 4
if (req1.readyState == 4)
{
// only if http status is "OK"
if (req1.status == 200)
{
document.getElementById('c
}
else
{
alert("There was a problem while using XMLHTTP:\n" + req1.statusText);
}
}
}
req1.open("GET", strURL1, true);
req1.send(null);
}
}
function populateAmount ()
{
var txtboxamt=document.getElem
var txt1=document.getElementBy
//alert(txt1);
txtboxamt.value=txt1.value
}
</script>
<td colspan="9"><input type="text" id="cse_search" name="q" size="31" OnKeyup="populateAmount();
</tr>
<tr>
<td>Amt: <input type="text" name="cur_code" size="7" id="cur_code" ></td>
you could add the code to a function, so you don't have to duplicate it
<html>
<head>
</head>
<body>
<input id="text1" type="text" onkeyup="document.getElementById('text2').value = this.value;" onchange="document.getElementById('text2').value = this.value;"/>
<input id="text2" type="text" />
</body>
</html>
<html>
<head>
</head>
<body>
<input id="text1" type="text" onkeyup="document.getElementById('text2').value = this.value;" onmouseup="document.getElementById('text2').value = this.value;" oninput="document.getElementById('text2').value = this.value;" onpaste="document.getElementById('text2').value = window.clipboardData.getData('Text');"/>
<input id="text2" type="text" />
</body>
</html>
you can put this:
textbox2.text = textbox1.text