Twitter Updates

Saturday 6 February 2010

Hyperlink to submit html forms

Some times you need a hyperlink to submit hidden form data. Example taken from javascript-coder.

< form name="myform" action="handle-data.php">
Search: < input type='text' name='query' />
< a href ="javascript: submitform()">Search< / a>
< / form>
< script type="text/javascript">
function submitform()
{
document.myform.submit();
}
< / script>


This is a suggestion from VelocityReviews, just change the look of the button:
< input type="submit" value="Submit" style="Border: none; background: none">


I ended up using a hyperlink to an URL that could then be intelligently parsed in my sinatra route, I would have had to have seperate get and post routes any way if I wantyed to stop the form appending ?lots=of&variab=les to the URL.

1 comment:

Unknown said...
This comment has been removed by a blog administrator.