I need to open a child window like the alert box,
I already created a popup for that, it is working, but I need the popup open like alert and want to enter data and update, required for editing data from a table, I need to open alert box while clicking the edit button, I already created a popup window to do that, I tried adding that code here...
code of main table is:
function poupdata(url){
window.open(url,"edit","width=500,height=550px");
}
<html>
<table>
<thead><tr><th>Sl No</th><th>head 1</th><th>head 2</th><th>head 3</th><th>Edit</th></tr></thead>
<tbody>
<tr><td>1</td><td>data 1</td><td>data 2</td><td>data 3</td><td><input type="button" value="Edit" onclick="poupdata('edit.php?slno=1')"></td></tr>
<tr><td>2</td><td>data 1</td><td>data 2</td><td>data 3</td><td><input type="button" value="Edit" onclick="poupdata('edit.php?slno=2')"></td></tr>
<tr><td>3</td><td>data 1</td><td>data 2</td><td>data 3</td><td><input type="button" value="Edit" onclick="poupdata('edit.php?slno=3')"></td></tr>
<tr><td>4</td><td>data 1</td><td>data 2</td><td>data 3</td><td><input type="button" value="Edit" onclick="poupdata('edit.php?slno=4')"></td></tr>
</tbody>
<table>
</html>
and the edit.php page like
<html>
<form method="POST"><table>
<tr><td>Data 1</td><td><input type="text" name="name"></td></tr>
<tr><td>Data 2</td><td><input type="text" name="name"></td></tr>
<tr><td>Data 3</td><td><input type="text" name="name"></td></tr>
<tr><td>Data 34</td><td><input type="text" name="name"></td></tr>
<tr><td></td><td><input type="submit" name="submit" value="Submit"></td></tr>
in this while clicking the submit button data read from the input fields and get updated in database,
and after updation sucessfull i need to close this and reload the main page automaticaly,
how can i do this
You can try and look at these examples, i am sure this is what you are looking for:
Bootstrap Modals
Modals Popup
Related
I have a webpage with three buttons, two of the buttons action the form submitting data to the server, it then sends back the appropriate page.
The third button is meant to just open a new webpage in a new tab, the current page does not need to be reloaded so this button is just a button element with some onclick() code, its is not part of an input element
The trouble is that when I click on the third button it actions the form action the form even though its not an input type, why does it do this ?
<main>
<form action="/license.process" name="process" id="process" method="post">
<label>
Please enter your license information as provided in your license email
</label>
<table>
<tr>
<td><label title="Email">Email</label></td><td><input type="text" name="licenseEmail" value="paultaylor#jthink.net" class="licenseinputfield"></td>
</tr>
<tr>
<td>
<label title="License Key 1">
License Key 1
</label>
</td>
<td>
<input type="text" name="licenseKey1" value="50302c02147f23ed809a8f2579338121a2b1594f967bb18" class="licenseinputfield">
</td>
</tr>
<tr>
<td>
<label title="License Key 2">
License Key 2
</label>
</td>
<td>
<input type="text" name="licenseKey2" value="0ff02146cd1777d7e0890e659b10218761869212d7b0d60" class="licenseinputfield">
</td>
</tr>
</table>
<input type="submit" name="cancel" value="Cancel">
<input type="submit" name="save" value="Save">
<button onclick="window.open('http://www.jthink.net/songkong/buy.jsp','_blank');">
Get License
</button>
</form>
</main>
I can make it work properly by moving this third button outside of the form. But then I get formatting problem because button is shown on next line, regardless I want to understand why having the butto within the form triggers the form.
The default type of a <button> is submit.
If you want it to be type=button then you have to say so explicitly.
You need to add the type="button" attribute to prevent the form from being submitted.
I'm not entirely sure why but came across this last week.
<body>
<form method="post">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="txtName" placeholder="Enter Your Name Please" /></td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="txtAdd" placeholder="Enter Your Address Please" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="btnSave" value="Click to Save Me...." /></td>
</tr>
</table>
</form>
When I Click Submit Button Data are Saved in Database.
But I want When i submit data data will save and print window should be open
Try with this one
For saving data and open print window in one click you have to use AJAX and on success of AJAX you can open print window. For this change your submit button to simple button and call ajax on button click.
OR
After submitting form you can add script tag instead of header function.
<script>
window.open(URL)
</script>
I have a big form in PHP with several tables, each of one calculates a sum (of price and quantity) and then there's one at the end that calculates the total.
The structure is, more or less, this:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="purchase_form">
<div id="purchase_1">
<table>
<input id="price_1">
<input id="quantity_1">
<input type="submit" name="calculate" value="Click here to calculate the partial">
</table>
</div>
<div id="purchase_2">
<table>
<input id="price_2">
<input id="quantity_2">
<input type="submit" name="calculate" value="Click here to calculate the partial">
</table>
</div>
<tr>
<td id="price_sum"><?php *script* ?></td>
<td id="quantity_sum"><?php *script* ?></td>
</tr>
</form>
Now, when I click on submit to calculate the "partial", it gives me the total, at the same time. I know it's not a state-of-the-art form, but anyway, just try to turn a blind eye on that.
What I want is, when I click on submit button, to have the page reloaded showing the form I have clicked on. Like, if I click on submit of the #purchase_1 table, I want the page to reload on #purchase_1 table, and so on.
Is it possible to do that with javascript?
I want to ask you guys how i can put a form method "Get" in a table. In my table i have got a text field and when i submit this form it will check for validation. My validation works fine but this form doest actually submit it as i don't aget any values at the URL.
<form method="GET" id="my_form">
<table>
<tr>
<td>
<input type="submit" name="submit" id="submit" value="submit" onclick="return submitvalidation();" form="contactusform">
</td>
</tr>
</table>
</form>
Your submit button belongs to a different form.
Remove
form="contactusform"
I am facing a problem. I have created a form where a user has to input the details about a candidate and also upload his/her image. The problem is that in the form there is a button that says "Click To Add More Candidate", so when this button is clicked the same form should reappear under a division called "moreCandidates". Now to achieve this how should I go about it? Things that are coming in my mind is as follows:
To create a function in javascript that exactly creates the form contents (ie. all the input fields,etc) and onclick of the button "Click To Add More Candidate", call the function under the mentioned division. I can do this as in the past I have done something very similar to this. However, this time I don't think it would be good idea to create the whole form again as I have written a PHP function in between to read a directory.
Or the second thought that I have is to have the form code written in a file called candidate.php and call that file with AJAX. The problem here could be that I might be calling the whole form again (whereas I just want to call the contents of the form like the candidate name, and other stuff)
I very confused at the moment, and help from you all would be greatly appreciated. Thanks in advance.
My html code:
<div id="candidateForm">
<table border="0">
<form method="post" action="formDetails.php" enctype="multipart/form-date">
<tr>
<td>Candidate Name:</td>
<td><input class="candidateForm" type="textbox" name="candidateName" placeholder="Candidate's Name"/></td>
</tr>
<tr>
<td>Enroll No:</td>
<td><input class="candidateForm" type="textbox" name="enrollNumber" placeholder="Enroll No"/></td>
</tr>
<tr>
<td>Candidate Image:</td>
<td><input class="candidateForm" type="file" name="candidateImage" placeholder="Select a Image"/></td>
</tr>
<tr>
<td>Cadidate Post:</td>
<?php
//This is the target folder that is going to be read.
$target="uploads/";
//I an using a directory function in PHP scandir() which scans tha contains of the give directory
$dir=scandir($target);
?>
<td>
<select name="candidatePost">
<option value="candidatePost" select="selected">---------Select---------</option>
<?php
foreach($dir as $folders)
{
//When we loop throung the target folder/directory we get this annoying two folder that is "." and ".." so just to rule then out i m using an IF condition
if($folders!="."&& $folders!="..")
//echo $folders;
echo "<option class='candidateForm' value=$folders>$folders</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>About The Candidate:</td>
<td><textarea name="aboutCandidate" cols="40" rows="5"></textarea></td>
</tr>
<div id="moreCandidates"> </div>
<tr>
<td></td>
<td><input type="button" value="Click To Add More Candidate"></input> </td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="candidateFormSubmit" value="Press Here To Submit The Details" onclick=""/></td>
</tr>
</form>
</table>
</div>