[thelist] How do I submit a single form thru either of two links using JavaScript AND pass a hidden value depending on the link?

Matt Warden mwarden at gmail.com
Wed Apr 20 11:50:02 CDT 2005

On 4/20/05, Ivo P <ipletikosic at gmail.com> wrote:
> The JavaScript:
> <script language="JavaScript">
> <!--
> document.write("<a
> href='javascript:document.myform1.submit()'>Download v1.0</a>");
> document.write("<br/>");
> document.write("<a
> href='javascript:document.myform1.submit()'>Download v1.0.1</a>");
> -->
> </script>

Why are you using JS for this?

> Clicking either link should submit the form myform1 but depending on
> which link was clicked an additional hidden value (say version='1.0'
> or version='1.0.1') should be sent back with the form.
> Any pointers on how to accomplish this?

Yes: don't.

Use two submit buttons:

<input type="submit" name="dlversion" value="Download v1.0" />
<input type="submit" name="dlversion" value="Download v1.0.1" />

Then there will be a form name/value pair of either:

dlversion=Download v1.0


dlversion=Download v1.0.1

Which is exactly what you'd get if you instead used a hidden field.

Matt Warden
Miami University
Oxford, OH, USA

This email proudly and graciously contributes to entropy.

More information about the thelist mailing list