Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IMPOSSIBLE PROBLEM??? 2

Status
Not open for further replies.

bublathejuggla

Technical User
Sep 21, 2002
16
GB
hi all.

got a major prob.

im using JSPS embedded in HTML to retrieve all 'user profiles' from a database. user profiles comprise of 'first_name', 'last_name' and 'user_type' attributes. the profiles are retrieved and placed row-by-row in separate cells in a HTML table of inputs (the reason for using HTML inputs is because the page is supposed to allow the user to change attribute values). when the page loads, current database attribute values of each user profile are shown in each cell (input text field).

the creation of each row in the HTML table is done dynamically using a java 'for' loop that checks it has retrieved ALL database entries. i have successfully implemented in the for loop, unique names for each row input field.

heres the prob:
the HTML table is part of a HTML form, and on submission ('onSubmit'), i want to use JavaScript to check the HTML table entries for database integrity i.e. no fields are empty. This is because, changes made to the user profiles will be updated to the system database. i have been able to pass to JavaScript, the length of the table using a java variable and now wish to use a 'for' loop in JavaScript for the checking. BUT, despite having unique names for each row's input fields, how can i perform these checks? please help!

heres the JavaScript check() method im using:

function check(no_of_user_profiles) {
for(i = 0; i < no_of_user_profiles; i++) {
if(document.formName.???????.value == &quot;&quot;) {
alert('Missing Entry');
}
}
}

the ??????s represent the unique name of the HTML input field im checking. for example, for the first row, the ?????? would be 'USERNAME1', for the second it would be 'USERNAME2', and so on...................
 
You should look into Document.getElementsByTagName, getElementsByName, and getElementById. I'm not sure how your naming the inputs, but one of these should prove to be a solution to your question.

-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
You could also name all the inputs the same, 'UserName' for example, and use this to loop through them:

document.formName.UserName.value == &quot;&quot;

Since all the inputs are named the same they'll become an array. ________________________
JoelMac
 
Hey! my square brackets disappeared. That line of code should read:

document.formName.UserName.value == &quot;&quot;

(I forgot to turn the Process TGM off)
________________________
JoelMac
 
You can also use the
Code:
tags if you still want tgml but you don't want it to render your code as tgml, everything inside the
Code:
 tags is left unrendered.
-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top