| re: form submit problem
Martin Nadoll wrote:
[color=blue]
> i try to submit a form with textlink like this snippet:
>
> <a href="javascript:document.bestellen.submit()">best ellen</a>[/color]
That's nonsense. "javascript:" is nonsense (see the FAQ) and nobody
can order without support for client-side scripting, although that would
not be necessary. Besides, the standards compliant reference would be
document.forms['bestellen'].submit();
If you have still problems with this, maybe the cause is that the "form"
element is located *after* the "link" or you may have tested with IE and
slided on the shared namespace of variables and element names/IDs in its DOM.
[color=blue]
> <form name="bestellen" method="post"
> action="myPage.cfm?ID=4300&do=action">
> <input name="category" type="hidden" value="2">
> <input name="Product" type="hidden" value="423">
> <input name="Price" type="hidden" value="15">
> <input name="action" type="hidden" value="basket">
> <input name="Quantity" type="hidden" id="Quantity" value="1">
> </form>
>
> but this results in a javascript error: this object dont use that method (or
> something, its in german).[/color]
With which user agent have you tested?
[color=blue]
> Where am i wrong here?[/color]
The code is error-prone and unreliable. Use something like
<form
name="bestellen"
method="post"
action="myPage.cfm?ID=4300&do=action">
<input type="hidden" name="category" value="2">
<input type="hidden" name="Product" value="423">
<input type="hidden" name="Price" value="15">
<input type="hidden" name="action" value="basket">
<input type="hidden" name="Quantity" id="Quantity" value="1">
<input type="submit" value="Bestellen">
</form>
instead. (If you don't like the style of the "submit" button, you can
change that with CSS [e.g. you can make it look like a link if you like].
You can even use type="image" to use an image as submit button. In
contrast to your present code, a submit button will work everywhere
[although type="image" support is restricted to more recent browsers].)
HTH
PointedEars
P.S.: de.comp.lang.javascript exists :) |