how to reset value with jquery form..my input text value with php. when I edit text and I reset, then back again to the value php..I've tried with jquery reset but input text
lost value.
<form>
<input type='text' id='chk' value='<?php echo $item.$i?>'/><br/>
<input type='text' value='<?php echo $item.$i?>'/><br/>
<input type='text' value='<?php echo $item.$i?>'/><br/>
<input type='reset' id='reset_button' value='reset'/>
</form>
when i edit input text and then i click reset.input text losing value?how to input text back to original value?
thanks..
You could use a form reset button: <input type='reset' value='Reset'/>
If you don't want the button to be visible, you could hide the button and call the click() method to reset the form.
Example:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h2>With button:</h2>
<form>
<input type='text' value='Foo'/><br/>
<input type='text' value='Bar'/><br/>
<input type='reset' value='Reset'/>
</form>
<br/>
<br/>
<h2>Without button:</h2>
<form>
<input type='text' id='chk' value='1'/><br/>
<input type='text' value='Foo'/><br/>
<input type='text' value='Bar'/><br/>
<input type='reset' id='reset_button' style='display: none;'/>
<input type='submit' onclick="if ($('#chk').val() == '0') $('#reset_button').click(); return false;" value='Check if 1 (reset if 0)'/>
</form>
Related
I have this form - How can I make the input on the text input go on the url?
<form class='divtabellinacenter' name='primo_form' action='elencoget.php".$url."' method=post>
Filtra per<br> Cognome <input class='emailtext' type=text id='filtrocognome' name=cognome value='Cogn' oninput=''>
<input type='hidden' id='savecognome' name='savecognome' value=''>
Nome <input class='emailtext' type='text' name='nome' id='filtronome' value='Nom' oninput=''>
<input type='hidden' id='savenome' name='savenome' value=''>
</form>
I have a 2 pages and I want to stay the data value that i passed from page1.php
page1.php
<form action='page2.php' method='POST' class='form-inline'>
<input type='submit' class='btn btn-info' value='Manage Child'
name='manage'>;
<input type='hidden' value='<?php echo $id;?>' name='id'>
</form>
page2.php
$id = $_POST['id'];
if(isset($_POST['passinfo'])){
$studentid=$_POST['studid'];
}else{
$studentid='';
}
<form>
<input type='hidden' name='parentid' value='<?php echo $id;?>'
<input type='hidden' name='studentid' value='<?php echo $studentid;?>'
<input type='text' name='studentname'>
</form>
<form action='' method='POST'>
<input type='hidden' name=studid value='<?php echo $stud_id?'>
<input type='submit' class='btn btn-primary' value='Assign' name='passinfo'>
</form>
my problem is if I click the 'passinfo' button and submit the 'studid' value the '$parentid' value will be unindentified variable. My question is how do I maintain the value of the '$parentid' even if I submit a form
You must place hidden inputs in one form:
<form action='' method='POST'>
<input type="hidden" name="parentid" value='<?=$id?>'>
<input type="hidden" name="studentid" value='<?=$studentid?>'>
<input type='hidden' name=studid value='<?=$stud_id?'>
<input type='submit' class='btn btn-primary' value='Assign' name='passinfo'>
</form>
I have a form, something like this:
<form action='index.php?page=search&filter=1'>
<input type='text' name='ID'>
<input type='text' name='number'>
<input type='submit'>
</form>
If I submit form, it will go to page:
index.php?ID=value1&number=value2
I would like to have
index.php?page=search&filter=1&ID=value1&number=value2
How can I append extra fields to url ?
Thank you for help.
you should put these values in hidden inputs:
<form action='index.php'>
<input type='hidden' name='page' value='search'>
<input type='hidden' name='filter' value='1'>
<input type='text' name='ID'>
<input type='text' name='number'>
<input type='submit'>
</form>
You can submit additional GET value as a hidden field value in the form which will be submit along with form submission.
<form action="index.php" method="get">
<input type='text' name='ID'>
<input type='text' name='number'>
<input type='hidden' name='page' value='search'>
<input type='hidden' name='filter' value='1'>
<input type='submit'>
</form>
Use hidden fields with your form and you will get exact url you want.
Try below code :
<form action="index.php" method="get">
<input type='hidden' name='page' value='search'>
<input type='hidden' name='filter' value='1'>
<input type='text' name='ID'>
<input type='text' name='number'>
<input type='submit'>
</form>
Try using some hidden input fields and use get method in form submitting.
Try this:
<form action="index.php" method="GET">
<input type='hidden' name='page' value='search' />
<input type='hidden' name='filter' value='1' />
<input type='text' name='ID' value='value1' />
<input type='text' name='number' value='value2' />
<input type='submit' value='Submit' />
</form>
Here is the form
form.php
<form name='formONE' action='form.php'>
<select name='multiselect[]' method='post'>
<option name='1'>one</option>
<option name='2'>tow</option>
<option name='3'>three</option>
<option name='4'>four</option>
</select>
<input type='submit' value='choosed' />
</form>
<form name='formTOW' action='form.php'>
<input type='text' name='text1' />
<input type='text' name='text2' />
<input type='text' name='text3' />
<input type='text' name='text4' />
<input type='text' name='selectedone' value='
<? foreach($_post['multiselect'] as $slct){print ", $slct";}' />
<input type='submit' value='save'/>
</form>
Here, on fromONE the user will select the options(some of option will be selected means selective) after the selection and submit the data will be passed to the form named formTOW input name = selectedone and after i submit formTOW data will pass to database.
but now here on formTOW if i input some value but in last if i select some data from formONE and submit the data of formTOW will be ears
here i want the formONE sumbit to do not make any change or effect on formTOW
regards
You can't put a form inside a form, this is just not allowed in HTML.
If you don't want to use javascript you can use the forms side by side. But it is just as easy to put everything in one form. Just ignore what you don't need when you evaluate the form values.
<form name='form' action='form.php'>
<input type='text' name='text1' />
<input type='text' name='text2' />
<input type='text' name='text3' />
<input type='text' name='text4' />
<input type='submit' value='save'/>
</form>
<form name='form1' action='form.php'>
<select name='multiselect[]' method='post'>
<option name='1'>one</option>
<option name='2'>tow</option>
<option name='3'>three</option>
<option name='4'>four</option>
</select>
<input type='text' name='selectedone' value='
<? echo implode(", ", $_POST['multiselect']); ?> />
<input type='submit' value='TransferToTnputTextFromSelect'/>
</form>
I had two forms
login form
Registration form
login form has the username and password fields and registration form consists controls for registration like username, city, country, etc.,
Also, I have some hidden controls like
<input type="hidden" name="ctrl1" />
<input type="hidden" name="ctrl2" />
<input type="hidden" name="ctrl3" />
<input type="hidden" name="ctrl4" />
Which is dynamically generated using PHP Code.
What I want is, When the user click login form's submit or the registration form's submit, the hidden controls data should also be Posted.
Insert the hidden inputs into both forms when you generate the page:
<form id='form1' action='' method='post'>
<input type='hidden' name='h1' value='v1' />
<input type='hidden' name='h2' value='v2' />
<input type='hidden' name='h3' value='v3' />
<input type='submit' name='submit' value='Submit Form 1' />
</form>
<form id='form2' action='' method='post'>
<input type='hidden' name='h1' value='v1' />
<input type='hidden' name='h2' value='v2' />
<input type='hidden' name='h3' value='v3' />
<input type='submit' name='submit' value='Submit Form 2' />
</form>
Use this example, definitely it will help you.
<SCRIPT LANGUAGE="JavaScript">
function runscript()
{
document.form1.submit();
document.form2.submit();
}
</SCRIPT>
<BODY>
<FORM METHOD=POST ACTION="http://localhost/login.php" NAME="form1">
<INPUT TYPE="text" NAME="text1">
</FORM>
<FORM METHOD=POST ACTION="http://localhost/register.php" NAME="form2">
<INPUT TYPE="text" NAME="text2">
</FORM>
<INPUT TYPE="button" value="Submit" onClick="runscript()">
</BODY>
Use jQuery's serialize on one of the forms.