i'm new to ajax and i have a simple text box and a combo box and i need whenever the user enters a text in the text box that value appears at the combo box or whatever field( another text box maybe )
Value entered in text box appears automatically in combo box (or text box)
Collapse
X
-
Do u really want to do this thing with AJAX, u can achieve this task wothout AJAX.
[HTML] <html>
<head>
<script type="text/javascript">
function doThis()
{
var x = document.getEle mentById('myTex t').value;
if(x==""||x==nu ll||x==false)
{
alert("Please Enter the Value in the Text Field");
document.getEle mentById('myTex t').focus;
}
else
{
document.getEle mentById('mySel ect').add(new Option(x,x));
}
}
</script>
</head>
<body>
Enter Text: <input type="text" id="myText" name="myText">
&nb sp;
<input type="button" value="Add to Combo" onclick="doThis ()">
<br/><br/>
<select id="mySelect" name="mySelect" >
<option>Selec t</select>
</select>
</body>
</html>[/HTML]
If u want to do it with Ajax, post the code what u have tried. I will try to help u out
Regards
Ramanan Kalirajan -
jessy, I have changed your thread title.
Please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).
This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.
Moderator.Comment
-
Thanks alot for you reply .. did what u said although i was trying to try something new (like ajax) but anyway, now i need when this value is added to the combo box the old option which is ( no data added ) be removed from the combo box
here's my trial :
where "no" is the name of the option i want to remove not the name of the select statementCode:var opt= document.getElementById("no"); opt.remove(0);Comment
-
Originally posted by jessyThanks alot for you reply .. did what u said although i was trying to try something new (like ajax) but anyway, now i need when this value is added to the combo box the old option which is ( no data added ) be removed from the combo box
here's my trial :
where "no" is the name of the option i want to remove not the name of the select statementCode:var opt= document.getElementById("no"); opt.remove(0);
Removing u can do easily
[HTML] var sel = document.getEle mentById('mySel ect').selectedI ndex;
document.getEle mentById('mySel ect').remove(se l);[/HTML]
This piece of code will do the work what u are aiming at.
Regards
Ramanan KalirajanComment
Comment