/    Sign up×
Community /Pin to ProfileBookmark

How to validate dynamic forum data?

hi
I am validating a form which has a table with rows added to it dynamically when the user clicks the “Add Row” button. all of the fields have the same name plus a number which is the number of the row which they are added in.this is a part of my function.

for(i=1; i< num_of_rows_in_my_table ; i++)
{
if (document.myform.[COLOR=blue]myselect+i[/COLOR].value==0)
{ //show error }
………
}
my problem is that I dont know what to use instead of myselect+i to make it working.

can anyone help me with this

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@TageMay 30.2004 — Maybe something like this?[code=php]for(i=1; i<= num_of_rows_in_my_table ; i++)
{
if (document.myform.elements["myselect"+i].value=="")
{ //show error }
.........
}[/code]
I added an equal sign after the less than operator, so if it doesn't work properly, take that out. And changed 0 to "" because I thought you were trying to check if the element was empty. x.x

Tage
Copy linkTweet thisAlerts:
@fatemehauthorMay 31.2004 — thanks ? ,it solved my problem ?
×

Success!

Help @fatemeh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...