Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

  (email not shown publicly)
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Tuesday December 21, 2004
04:43 PM

Javascript woes

[ #22404 ]

Given the following form:

<form id="test" action="" method="post">
<input type="hidden" name="action" value="example">

What will document.forms.test.action and document.forms.test.getAttribute('action') be?

The former is the hidden field, the latter is the form's action.

The problem was that I couldn't change the HTML and had to pass the form to somebody else's javascript which assumed that form.action would work. After a bit of head scratching, I found the workaround isn't too painful:

var form = new Object();
form.action = test.getAttribute('action');
test.setAttribute('action', form.action);

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.