Well, I have this form tag which works perfectly.
<form action="searchresult.php" method="post">
<?php
require('connect.inc');
$sql1="SELECT room_type,room_id FROM room";
$result1=mysql_query($sql1);
echo "<select name=roomtype value=''></option>";
while($nt=mysql_fetch_array($result1)){
echo "<option value=$nt[room_type]>$nt[room_type]</option>";
}
echo "</select>";
mysql_close();
?>
</td>
<td>
<input type='hidden' name='clientid' value="<?php echo $clientid; ?>">
<input type="text" class="w8em format-y-m-d highlight-days-67 range-low-today" name="chkin" id="sd" value="" maxlength="20" readonly />
</td>
<td>
<input type="text" class="w8em format-y-m-d highlight-days-67 range-low-today" name="chkout" id="ed" value="" maxlength="20" readonly />
</td>
</tr>
</table>
<input type='submit' name='submit' id="button1" value="Check Room Availabilty">
</form>
This opens up to a new page named "searchresult.php"
But,what I need to know is, how to display this .php file in a pop up style.
I am currently using facebox as my pop up,and I use it like this:
<a rel="facebox" href="searchresult.php">Check Room Availability</a>
But to no success, the inputs are not passing to the next page,so I get errors.
I know variables can be pass through the a tag like this
echo'<a rel="facebox" href=editroom.php?id=' . $row3["room_id"] . '>' . 'Edit' . '</a>';
But my case now is , I need the inputs to be pass.
I declare this codes in every page.
<link href="src/facebox.css" media="screen" rel="stylesheet" type="text/css" />
<script src="src/facebox.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox({
loadingImage : 'src/loading.gif',
closeImage : 'src/closelabel.png'
})
})
Thanks.
If you are using jQuery you could attach a method to the form submit to call
jQuery.facebox({ ajax: 'searchresult.php' });
You will ofcourse have to pass some URL parameters in order for it to display the relevant results
Something like this will work:
$('#search').submit(function() {
$.facebox({ ajax: 'searchresult.php?search=&search2=' });
return false;
});
Related
Hi I try to sum two data using AJAX and display it into hidden text input after that, I will pass the variable using PHP post method.
There are no problems in my jQuery AJAX code but the problem is after I submit the button, the value I retrieve from textbox total_rec[] is blank.
Here's my code below.
HTML:
<form method="post" action="<?php echo base_url() ?>user/recitem_insert">
<table>
<thead>
<tr><th>Test</th></tr></thead>
<tbody>
<tr><td>
<input type="hidden" name="last_item_rec[]" value="<?php echo $row->rec_qty; ?>">
<input type="text" name="item_rec[]" id="txt" disabled="">
<input type="hidden" name="total_rec[]" value="">
</td><tr>
</tbody>
</table>
</form>
JQUERY AJAX:
<script>
$(document).ready(function(){
$("input[name=item_rec\\[\\]]").on('keyup',function(){
var one = $(this).parents('tr').find('input[name=last_item_rec\\[\\]]').val();
var two = $(this).parents('tr').find('input[name=item_rec\\[\\]]').val();
sum = parseInt(one) + parseInt(two);
$(this).parents('tr').find('input[name=total_rec\\[\\]]').val(sum);
});
});
<script>
PHP CODE: (recitem_insert.php)
$total_rec = $_POST['total_rec'];
for($i=0;$i<sizeof($check);$i++){
for($j=0;$j<sizeof($total_rec);$j++){
$query=mysqli_query($con,"UPDATE tblstock
SET
rec_qty='$total_rec[$j]'
WHERE id = '$check[$i]'
")or die(mysqli_error($con));
}
}
As you told that the item contain 2 or more value. So you can use class instead of name.
HTML
<input type="hidden" class="last_item_rec" name="last_item_rec[]" value="23" />
<input type="text" class="item_rec" name="item_rec[]" id="txt" />
<input type="hidden" class="total_rec" name="total_rec[]" value="" />
jQuery
$(function(){
$(".item_rec").on('keyup',function(){
var one = $(this).parents('tr').find('.last_item_rec').val();
var two = $(this).parents('tr').find('.item_rec').val();
sum = parseInt(one) + parseInt(two);
console.log(sum);
$(this).parents('tr').find('.total_rec').val(sum);
});
});
I have the code below that gets an id if there is any and asks you to click a button to show you data.
<input type="text" id="date" value="<?php echo $_GET['id']?>" class="css-input" placeholder="Posting Date..." readonly="readonly" /><br /><br />
<input type="button" id="validate" value="Let's get to work!" class="btn" />
The code below takes you to the data automatically without needing to click a button if there is an id there.:
jQuery(document).ready(function() {
jQuery("#validate").click();
});
How can I do an if statement that if #validate is not null then execute the jQuery code else don't. How could I do that whenever I do <?php if(#date != null) I get an error, any ideas?
<?php
if($_GET['id'] != NULL){
?>
<script>
jQuery(document).ready(function()
{
jQuery("#validate").click();
});
</script>
<?php }?>
</head>
Please help..
Here's a dynamic 10-row html table with datetimepicker input area. I need to get all the datetime values but only the last cell data is available. What is wrong with the code?
<form action="atab.php" method="post">
<table>
...
while ($data=mysql_fetch_assoc($query)){
echo"<tr>";
...
<td><input class="datetimepicker" type="text" name="datet" />
<script>
$(function() {
$( ".datetimepicker" ).datetimepicker();
});
</script>
</td>
<?php
echo"</tr>";
}
}
echo'</table><input id="subm" class="btn btn-sm btn-success" type="submit" name="subm" value="Send" /></form><hr />';
...
and some php:
<?php
$date=array($_POST['datet']);
foreach ($date as $value){
echo $value;
}
You may have to declare the input name as an array type
<input class="datetimepicker" type="text" name="datet[]" />
then
$date=$_POST['datet'];
Also there is no need to initialize the plugin within the loop, move the below lines out of the loop
$(function() {
$( ".datetimepicker" ).datetimepicker();
});
replace
<input class="datetimepicker" type="text" name="datet" />
to
<input class="datetimepicker" type="text" name="datet[]" />
and try this:
<?php
foreach ($_POST['datet'] as $value){
echo $value."<br>";
}
I'm new here and a super noob in programming. I'm having trouble with my project. My problem is that I'd like hide the form after submit and retain the data input in it.
Here's my code:
<?php
$displayform = true;
if (isset($_POST['trck']))
{
$track = addslashes(strip_tags($_POST['tracknumber']));
$ord = $_POST['id'];
$displayform = false;
if (!$track)
echo "Please enter your tracking number!";
else
{
mysql_query("update `orderdetails` set `trackno`='$track' where `id`='$ord'");
}
if ($row2['id']==$ord)
echo $_POST['tracknumber'];
}
if ($displayform)
{
?>
<form method="post" action="">
<input type="text" name="tracknumber" id="tracknumber" size="30" maxlength="30" placeholder="Enter your track number here." />
<input type="hidden" name="id" value="<?php echo $row2['id']; ?>">
<input type="submit" name="trck" id="trck" value="Save" onclick="return confirm(\'Are you sure you want to save this tracking number?\');" />
</form>
</td>
</tr>
<?php
}
}
?>
This code was inside a while loop and my problem with this is that after I submit all the form is hidden. All I want is to hide the form with the specific ID on a query.
Simplest way is to use jQuery hide
Include the jquery as
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
$("#buttonid").click(function(){
$("#formid").hide();
});
You are looking for something like this in your <form> tag:
<form method="post" action="" id="awesome_form" onSubmit="document.getElementById('awesome_form').style.display = 'none';">
use the jQuery and use :
$("#submitButtonId").click(function(){
$('#formId').hide();
});
or else in pure javascript use
<input type="submit" value="submit" onClick="hideIt()"/>
<script type="text/javascript" >
function hideIt() {
document.getElementById('formId').style.display = 'none';
}
</script>
its better not to use inline javascript
I have 3 pages.
a1.php : add record
a2.php : do sth
a3.php : record them database
But problem is occured, transfering "html data" from a2.php to a3.php.
EXAMPLE: a record which I try to record to a1.php is that :
<form name="form1" type="post" action="sayfa_1.php">
<input type='submit' value=' gidiyoruz' >
<input type='submit' value=' gidiyoruz' >
</form>
a1.php --> a2.php --> a3. php
On a2.php, there i no problem. But then. On a3.php when I show coming data, I SEE TWO BUTTON, NO HTML CODES which is above.
pages is below.
thanks.
a1.php
<script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script> <script type="text/javascript">
//<![CDATA[
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
//]]>
</script>
<form name="form1" type="post" action="a2.php">
<textarea rows="20" cols="90" id="anlam" name="anlam" style="overflow:auto;" > </textarea>
<input type="submit" />
</form>
a2.php
<?php
$anlam=$_GET["anlam"];
echo $anlam;
?>
<?php echo "<form name='fm' id='fm' action='a3.php' method='get'>"; ?>
<textarea rows="2" cols="50" name="anlam" style="visibility:hidden;" /> <?php echo $anlam; ?> </textarea>
<input type="submit" />
</form>
a3.php
<?php
$anlam=$_GET["anlam"];
echo nl2br($anlam);
Pace images are above. error: a3.php (instead code, there are two button)
so you want the page to send your data from one to another when you click submit button!!
Use if condition with isset.
if(isset($_POST['name_of_submit_button']))
{
// your code of next page
}
n similarly continue with another page by giving another name to you submit button and applying the same condition!!
Try using
method="post"
for your form. You could also just use an
<input type="hidden" name="anlam" value="<?php echo $anlam; ?>"/>
to transport your variable content to the last page. Are you sure, that the hidden textarea/input contains the correct value? Check the source code in your browser for this step.