stuck on how to access a textfield added in a div
- From: "Ed" <edwardquick@xxxxxxxxxxx>
- Date: 30 Oct 2005 04:35:04 -0800
Hi,
I'm stuck at the moment trying to work out how to access the value of a
textfield which gets added in a DIV element.
I have functions to add and remove the textfields from the elements as
shown here:
function addListen(){
var ni = document.getElementById('listendiv');
var numi = document.getElementById('listendivval');
var num = (document.getElementById("listendivval").value -1)+
2;
numi.value = num;
var divIdName = "listen"+num;
var newdiv = document.createElement('div');
newdiv.setAttribute("id",divIdName);
var htmlstr="<td><input type=text id="+divIdName+"
name="+divIdName+" size=21 maxlength=21 /> ";
htmlstr=htmlstr+"<input type=button value=\" -\"
onclick=\"javascript:removeListen(\'" + divIdName + "\');\"> ";
htmlstr=htmlstr+"<input type=button value=\" +\"
onclick=\"javascript:addListen();\" /></td>";
newdiv.innerHTML=htmlstr;
ni.appendChild(newdiv);
}
//remove a listen textfield in the apache config form
function removeListen(divNum){
var d = document.getElementById('listendiv');
var olddiv = document.getElementById(divNum);
d.removeChild(olddiv);
}
And I'm trying to write a function here to verify the contents of the
new textfields added:
//check listen values
function checklistens(divNum){
var num = document.getElementById("listendivval").value;
var lnum= "listen"+num;
var numi = document.getElementById(lnum).value;
alert("numi="+numi);
var numi = document.getElementById(lnum).focus;
return false;
}
However I keep getting an undefined object in the alert. Can anyone see
what I'm doing wrong please?
Thanks,
Ed.
.
- Prev by Date: Re: static menu on the right
- Next by Date: Help ! Shopping Cart Problem
- Previous by thread: Re: finding out if a string contains characters
- Next by thread: Off Topic: Width of text input box vs. password input box
- Index(es):