have tried searching for this with no success. I want to be able to add urls to a table from textbox values then return these to a MVC controller POST action. Have tried the below but the submit click is triggering the post back to the server rather than executing the jquery code.
<h2>Index</h2>
@using (Html.BeginForm())
{
<input type="text" name="input" id="Text1"/>
<input type="submit" value="Submit" id="submit"/>
}
<div class="table-responsive">
<table class="table" id="table1">
<tr>
<th>Site</th>
</tr>
<tr>
<td>www.example.com</td>
</tr>
</table>
</div>
@using (Html.BeginForm("WebDriver", "Home", FormMethod.Post))
{
<input type="submit" value="Complete" id="complete" />
}
<script type="text/javascript">
$(document).ready(function () {
$('#submit').click(function(){
var val1 = $('input[id="Text1"]').val();
for (var i = 0; i < val1; i++) {
$('table[id="table1"]')
.append(' <tr class="row">' + val1 + '</tr>');
}
});
});
</script>