/    Sign up×
Community /Pin to ProfileBookmark

Checking objects created with appendchild

I am creating a form with an unlimited number of input boxes for sets of hardware and serial numbers. The user could press a button to generate (via appendchild) two new input boxes named newHardwareInputX and newSerialInputX, where X is an integer which increases by one for each new set of inputs.

Before populating the form with the new set of input boxes, I wanted to check the previous set using something like the following function to make sure there was something typed into those boxes:

if ((Form.NewHardwareInput1.value == “” || Form.NewSerialInput1.value == “”))
{Form.NewHardwareInput1.focus();
alert (“Please enter a Product and Serial number for each new component”);
return false}

My question is: I’m not sure how to replace the 1 in the previous example with a variable. I think I’m getting my quote placement screwed up.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@SpectreReturnsJul 12.2005 — <i>
</i>if ((Form["NewHardwareInput"+number].value == "" || Form["NewHardwareInput"+number].value == ""))
{Form["NewHardwareInput"+number].focus();
alert ("Please enter a Product and Serial number for each new component");
return false}
Copy linkTweet thisAlerts:
@dstoreauthorJul 13.2005 — Thanks Spectre, worked great.
×

Success!

Help @dstore 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.17,
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,
)...