My web application has a form with some image buttons, each button represents a task, when you click on the button it is posted to the /start
URL and then I decode which button is clicked and also the value of the form from the httpRequest
.
<form action="/start" method="post">
<input type="image" value="Status Report" name="statusreport" src="style/images/status_report.png" title="Status Report" data-toggle="tooltip" data-placement="bottom" class="btn btn-outline-primary btn-lg">
<input type="image" value="Fix Songs" name="fixsongs" src="style/images/fixsongs.png" title="Fix Songs" data-toggle="tooltip" data-placement="bottom" class="btn btn-outline-primary btn-lg">
<input type="text" name="folder" id="folder" class="form-control" value="C:\Music" aria-describedby="selectfolderaddon">
</form>
I have now added a navbar
(using Bootstrap 4), I have included the same tasks on the navbar
.
<ul class="navbar-nav">
<li class="nav-item">
<a href="" class="nav-link">
Status Report
</a>
</li>
<li class="nav-item">
<a href="" class="nav-link">
Fix Songs
</a>
</li>
</ul>
So how do I get it so when user clicks on link that the form is submitted and it looks like the equivalent image button has been clicked. i.e. I would prefer my server code not to have to handle two different ways to do the same thing. I suppose I use onclick()
- but what do I put into it.
i.e. I could use onclick
to submit the form, but it would not also set the correct image button, i.e. the server would receive the post request but without either of the input type images having been pressed, so the server would not know what the request was.