I am using CodeIgnighter framework. In my view I want to change the page when I click the button.
I set the base_url correctly.
Insert
Modify
You can also do it like this :
<form action="imports/add_user">
<input type="submit" value="Insert">
</form>
<form action="imports/modify_user">
<input type="submit" value="Modify">
</form>
Related
I am developing a web application using spring boot, spring mvc and thymeleaf.
I have in template two nested forms with different action and two submit buttons as following:
<form name="form1" action="#" th:action="#{/action1}" method="post">
...
<form name="form2" action="#" th:action="#{/action2}" method="post">
...
<button type="submit" value="Import"/>
</form>
...
<button type="submit" value="Validate"/>
</form>
How to let button "Import" submit form2 not form1...??
Thank you.
You can not have nested forms because a form can not have another form as descendants. You can have many forms in a body not nested as you know. You can have one set for import and another set for remaining by sharing common backbean.
Please refer the link
4.10.3 The form element
Content model:
Flow content, but with no form element descendants.
<body> <form id="outer-form" class="form-horizontal form" th:action="#{/urlOuter}" th:object="${myBackBeanObject}" method="post">
<fieldset id="form-fieldset">
<button id="save" name="save" class="btn btn-primary">Outer Save</button>
</fieldset>
</form>
<form id="inner-form" class="form-horizontal form" th:action="#{/urlInner}" th:object="${myBackBeanObject}" method="post">
<fieldset id="form-fieldset">
<button id="save" name="save" class="btn btn-primary">inner Save</button>
</fieldset>
</form></body>
I have a upload button but after i upload something i does not refresh the page. i thougt this would work but is doesnt:
function refreshPage(){
window.location.reload();
}
<span class="ff-b white ttu f21">UPLOAD<input type="button" onClick="refreshPage()"/>Close</span>
Do some body of you know how to fix this ?
Kind regards.
<form action="upload.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
In a frontend new custom post creation form, I'm trying to replace a normal input type file with dropzone, but it doesn't upload the images to the server.
I have created a new div for dropping the files, and I have wrapped the previous input as a fallback inside my form:
<form id="new_post" name="new_post" method="post" action="#" class="dropzone" enctype="multipart/form-data">
<!-- other form fields here -->
<div class="dropzone-previews"></div>
<div class="fallback">
<input type="file" name="file[]" multiple="multiple" />
</div>
<input type="hidden" id="new_cpt_action" name="new_cpt_action" value="new_cpt" />
<input type="submit" value="submit" id="submit" name="submit" />
</form>
To make dropzone work with the code above, I have the following options in my script:
$(document).ready(function () {
Dropzone.autoDiscover = false;
$("#new_post").dropzone({
uploadMultiple: true,
addRemoveLinks: true,
previewsContainer: ".dropzone-previews",
});
});
When I click the submit button, the creation of the new post is triggered and everything works as expected, but the images are not uploaded and attached. The input type="file" works perfectly, but dropzone doesn't.
If the server is able to handle the files with a normal input, does anyone know I am missing on the dropzone option?
Many thanks!
I'm building a form to integrate in WordPress. How can i prevent the form from displaying start.php as an new single page when submitting?. I would like to stay in the startform div inside the template. Right now I'm shipped to a new start.php page?
I've tried to change the action to correct path to start.php but it's still same problem?
My file is start.php, I'm using this code to display it:
<div class="startform">
<?php get_template_part( 'start' )?>
<div>
The form is in start.php:
<form method="post" action="start.php">
<input type="submit" id="up_vote" name="vote" value="newmember" />
<input type="submit" id="down_vote" name="vote" value="oldmember" />
</form>
I found my solution by adding the insert script on same page instead of action="start"
<form method="post">
<input type="submit" id="up_vote" name="vote" value="newmember" />
<input type="submit" id="down_vote" name="vote" value="oldmember" />
</form>
I'm just learning javascript and php. I created a contact form and I'd like the submit button to accomplish two things when I press it:
submit the data to me (this part is working)
read my onclick function (this part is not working)
<input id="submit" name="submit" type="submit" value="Submit" onclick="eatFood()">
<?php
if ($_POST['submit']) {
////?????
}
?>
I'm sending the data to my email, and so I get that. But the onclick function doesn't seem to work. I tried reviewing add onclick function for submit button but it didn't help.
I need to see your submit button html tag for better help. I am not familiar with php and how it handles the postback, but I guess depending on what you want to do, you have three options:
Getting the handling onclick button on the client-side: In this case you only need to call a javascript function.
function foo() {
alert("Submit button clicked!");
return true;
}
<input type="submit" value="submit" onclick="return foo();" />
If you want to handle the click on the server-side, you should first make sure that the form tag method attribute is set to post:
<form method="post">
You can use onsubmit event from form itself to bind your function to it.
<form name="frm1" method="post" onsubmit="return greeting()">
<input type="text" name="fname">
<input type="submit" value="Submit">
</form>
html:
<form method="post" name="form1" id="form1">
<input id="submit" name="submit" type="submit" value="Submit" onclick="eatFood();" />
</form>
Javascript:
to submit the form using javascript
function eatFood() {
document.getElementById('form1').submit();
}
to show onclick message
function eatFood() {
alert('Form has been submitted');
}
if you need to do something before submitting data, you could use form's onsubmit.
<form method=post onsubmit="return doSomething()">
<input type=text name=text1>
<input type=submit>
</form>
I have this code:
<html>
<head>
<SCRIPT type=text/javascript>
function deshabilitarBoton() {
document.getElementById("boton").style.display = 'none';
document.getElementById("envio").innerHTML ="<br><img src='img/loading.gif' width='16' height='16' border='0'>Generando...";
return true;
}
</SCRIPT>
<title>untitled</title>
</head>
<body>
<form name="form" action="ok.do" method="post" >
<table>
<tr>
<td>Fecha inicio:</td>
<td><input type="TEXT" name="fecha_inicio" id="fecha_inicio" /></td>
</tr>
</table>
<div id="boton">
<input type="submit" name="event" value="Enviar" class="button" onclick="return deshabilitarBoton()" />
</div>
<div id="envio">
</div>
</form>
</body>
</html>
Create a hidden button with id="hiddenBtn" and type="submit" that do the submit
Change current button to type="button"
set onclick of the current button call a function look like below:
function foo() {
// do something before submit
...
// trigger click event of the hidden button
$('#hinddenBtn').trigger("click");
}
<button type="submit" name="uname" value="uname" onclick="browserlink(ex.google.com,home.html etc)or myfunction();"> submit</button>
if you want to open a page on the click of a button in HTML without any scripting language then you can use above code.