/    Sign up×
Community /Pin to ProfileBookmark

Super-Easy JS question

Argh, it’s crazy how hard it is to find an answer to this. I have this code:

onclick=”autocopy(this.form,’source’,’target’);”

Which I want to refer to another form, not the form it’s in. I have no idea how to change “this” to “that”.

That’s all. ? And on a related note, I am assuming it’s not a problem for the onclick to occur in a form after the form it refers to?

Thank you….

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@felgallMar 08.2007 — <form name="that">

onclick="autocopy(document.that,'source','target');"
Copy linkTweet thisAlerts:
@TygerTygerauthorMar 08.2007 — Simple as that eh. Thank you very much!

One further question, is it possible to refer one argument to one form and one argument to another form? The source being in one form and the target being in another. The javascript it is referring to is this:

<script type="text/javascript">

function autocopy(f) {

for (var i = 1; i<arguments.length; i+=2)

f.elements[arguments[i+1]].value = f.elements[arguments[i]].value;

}

</script>
×

Success!

Help @TygerTyger 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.28,
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,
)...