Codeasearch.com - Search your code with us Login | Register | Contact us
  Forums > Javascript > input box count
thiyaghuck
Posted on Apr 27, 2009
Join Date: November 2008
Location: India ( chennai )
Posts: 14
 
input box count  

Hi,

I have about 10 input box in html,which is loaded dynamically from javascript. Now i need the count of all the input boxes which should be done in javascript. Can anyone help me in this?

Regards,
Thiyaghu CK.

benaya
Posted on Apr 27, 2009
Join Date: June 2007
Location: India ( Chennai )
Posts: 90
 
RE : input box count  

Hi,
Try with this script.

<script language="javascript">
function txtvalid(intCnt) {
for(intI=1;intI<=intCnt;intI++) {
if(document.getElementById("txt"+intI).value=="") {
alert("Please enter text"+intI);
document.getElementById("txt"+intI).focus();
return false;
}
}
}

function txt(intCnt) {
for(intI=1;intI<=intCnt;intI++) {
document.write("text"+intI+" : <input type='text' name='txt"+intI+"' id='txt"+intI+"' /><br />");
}
}

</script>
<form onsubmit="return txtvalid(3);">
<script>txt(3);</script><br />
<input type="submit" name="btn" value="Submit" />
</form>

balaji
Posted on Apr 27, 2009
Join Date: February 2009
Location: India ( chennai )
Posts: 9
 
RE : input box count  

just put it in a for loop to get the count-simple.

 Hot Discussion
Go Tech launches Android tablet for Rs 3,999...
Sony targets retailers with quick sales pitches and rew...
Share and discover new activities with Google Schemer...
Samsung gets 9 mn preorders for Galaxy S3: Report...
Google revamps search engine to think like a person...
 
 Discussion Topics
IT News
Php
Javascript
Technology Updates
Asp.Net
MySql
Ajax
Html
Fedora
Software Testing
Asp
Java
General
Flash
Ruby on Rails