/    Sign up×
Community /Pin to ProfileBookmark

Sending HTML input as an object in javascript function’s argument

HTML:

[code]
Password:<input name=”passwordField” class=”field”>
<button name = “randomize” value = “randomize” class = “button”
onClick=”randomizePassword(passwordField,15,allowSmall,allowNum,allowSymbol, allowPronou);”>Randomize</button><br>
<input type=checkbox NAME=”allowSmall” checked>Uses small alphabets<br>
<input type=checkbox NAME=”allowNum” checked>Uses numbers<br>
<input type=checkbox NAME=”allowSymbol” checked>Uses symbols<br>
<input type=checkbox NAME=”allowPronou” checked>Uses Latin-1 Supplement<br>
[/code]

Recently, I am trying to send those checkboxes and a field input into the javascript’s argument as objects, but they are not working at all.

I’ve already included the javascript .js file into the HTML code. It does work correctly, because I can invoke other methods in that .js file.

The onClick of the button also work correctly. I’ve tested that.

The Javascript function “randomizePassword” in the HTML above does not even get called. I have tried put an alert(“1”) in the first line of that function, but no sign of alert at all.

IMO, It should all come down to “how to pass objects as arguments correctly”. I’ve tried google for it around, I have tried follow some examples, but it still does not work. If anybody has any solution, please help. ?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangFeb 19.2009 — Probably a missing bracket in the script section; run it through JSLint.
Copy linkTweet thisAlerts:
@untitled_txtauthorFeb 19.2009 — Nope. No errors in javascript at all.

I've verified the codes and the problem is with passing those inputs with those names of passwordField, allowSmall, etc. above. I have tried send only integers to the function and it works. I think the program got confused in the onClick part there. Do I have to tell or sort of initialize these "names" somewhere in order to use those HTML inputs in the code?

Or better, maybe I should just tell what I am trying to do. I am trying to randomize some texts with respect to several checkboxes and put it in a input text field. I need a way to change the value of that text field after the user presses a button. I also need a way to refer to those checkboxes so that javascript can behave correctly according to these checkboxes.
Copy linkTweet thisAlerts:
@FangFeb 19.2009 — If you are passing [I]names [/I]then use quotesrandomizePassword('passwordField',15,'allowSmall','allowNum','allowSymbol', 'allowPronou')
×

Success!

Help @untitled_txt 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 5.6,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...