Recipe 7.11. Making an HTML Text Link Operate Like a Submit Button


Problem

You want to make an HTML text link execute a form.

Solution

Use JavaScript to trigger the form:

<form name="msgform" method="get" action="results.php"> <label for="fmmsg">Message</label> <textarea name="fmmsg" accesskey="m"  rows="5" cols="14"></textarea> <a href="javascript:document.msgform.submit(  );">Submit</a> </form>

Discussion

While Recipe 6.10 showed how to disguise a Submit button to look like HTML text, this recipe showcases how to make a text link work as a Submit button. The main negative to this approach is that the user needs to have JavaScript in order for it to work. Browsers without JavaScript or ones that have JavaScript turned off will not be able to use the form.

See Also

Recipe 7.10 for creating a Submit button that looks like an HTML text link.




CSS Cookbook
CSS Cookbook, 2nd Edition
ISBN: 0596527411
EAN: 2147483647
Year: 2006
Pages: 235

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net