AW: AW: [Javascript] Re: one form, two submit ways
Hakan M (Backbase)
hakan at backbase.com
Thu Mar 3 07:42:57 CST 2005
It's not really dirty, as long as you're accessing the attributes and
elements correctly. That is, as long as you're not accessing attributes
the IE-way.
Consider this:
--
<form action="load.php">
<input type="text" name="action"/>
</form>
myform['action'].value = 'save.php';
--
With IE's completely anal way of mapping everything to everything, you
have no clue as to if you're changing the 'action'-attribute on the form
tag itself (in a bad way), or if you are actually changing the value of
the input tag inside it.
The correct way is to use the DOM-functions getAttribute and
setAttribute, but as noted earlier this week, this doesn't work all that
good either, at least far from everywhere.
Something like this:
--
myform.elements['action'].setAttribute('value', 'myNewValue');
--
Regards,
H
Michael Borchers wrote:
>>-----Ursprüngliche Nachricht-----
>>Von: Kim Hoogenberg [mailto:kim.hoogenberg at virgil.nl]
>>Gesendet: Donnerstag, 3. März 2005 14:18
>>An: [JavaScript List]
>>Betreff: Re: AW: [Javascript] Re: one form, two submit ways
>>
>>
>>why don't you just use something like:
>>
>><input type="button" name="book" value="Book!"
>>onclick="document.forms['bookForm'].submit()">
>><input type="button" name="print" value="Print!"
>>onclick="document.forms
>>['printForm'].submit()">
>>
>>Or
>>
>><input type="hidden" name="subaction" value="">
>><input type="button" name="book" value="Book!"
>>onclick="document.forms['form'].subaction.value='book';document.forms
>>['form'].submit()">
>><input type="button" name="print" value="Print!"
>>onclick="document.forms
>>['form'].subaction.value='print';document.forms['form'].submit()">
>>
>>Hope this helps.
>>
>>Greetz,
>>
>>Kim
>
>
> works very fine, thanks.
> so, i guess using "action" as a name for a hidden field is quite commen, isn't it?
>
> but still, is it a little bit "dirty", because the form name already has an "action" tag?
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
More information about the Javascript
mailing list