Create linked time input - HTML/PHP/JAVASCRIPT - php

I need to "link" the two input forms so if i select a certain time, the second input will not display times before the choosen one.
ex: I select 16:30, the second input displays: 17:00, 17:30, 18:00, etc...
sorry for my bad english. here's the code. I think i need to use JS to hide other objects but i don't know how to do it.
Thanks for help
<div class="input-group">
<!--start time-->
<span class="input-group-addon"><div class="ciao">Inizio</div></span>
<select class="form-control" name="start">
<?php $orari=h oursRange(12 * 3600, 20 * 3600, 30 * 60);
foreach ($orari as $key=>$value) {
echo "<option>$value</option>";
} ?>
</select>
</div>
<!--end time-->
<div class="input-group">
<span class="input-group-addon"><div class="ciao">Fine</div></span>
<select class="form-control" name="end">
<?php foreach ($orari as $key=>$value)
{
echo "<option>$value</option>";
} ?>
</select>
</div>

I would suggest you look at jQuery Timepicker: http://jonthornton.github.io/jquery-timepicker/
Here is an example you can use with your code after downloading timepicker:
<div id="timepicker">
Inizio: <input type="text" class="time start" name="start" />
Fine: <input type="text" class="time end" name="end" />
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.timepicker.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.timepicker.css" />
<script type="text/javascript" src="lib/bootstrap-datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="lib/bootstrap-datepicker.css" />
<script type="text/javascript" src="lib/site.js"></script>
<link rel="stylesheet" type="text/css" href="lib/site.css" />
<script src="http://jonthornton.github.io/Datepair.js/dist/datepair.js"></script>
<script src="http://jonthornton.github.io/Datepair.js/dist/jquery.datepair.js"></script>
<script>
$('#timepicker .time').timepicker({
'showDuration': true,
'timeFormat': 'g:ia'
});
$('#timepicker').datepair();
</script>
Hope this helps!

Related

Fetch data from database in php

Hi In my application I designed one form with HallTicketNo if i click the submit button it will goto result page based on the hallticket no i want to fetch all the details.My proble is result.php it showing blank page fetching is not working can anyone help me
index.php:
<html>
<head>
<link rel="stylesheet" type="text/css" media="all" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/style_register.css" />
<link rel="stylesheet" type="text/css" media="all" href="css/responsive.css">
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/validation_script.js"></script>
</head>
<body>
<hr>
<img src="images/banner1.jpg" width="100%" />
<hr>
<section id="container">
<form id="result form" action="result.php" method="POST" enctype="multipart/form-data">
<div>
<label class="desc" id="title1" >Hall Ticket No.</label>
<div>
<input id="name" name="uname" type="text" class="field text fn" value="" size="8" tabindex="1">
<span class="val_name"></span>
</div>
</div>
<div>
<div>
<input type="submit" name="submit_registration" value="Submit" /><input type="reset" name="reset" value="Reset" />
</div>
</div>
</form>
</section>
</body>
</html>
result.php:
<?php
session_start();
if (isset($_SESSION['id'])) {
?>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" media="all" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/style_register.css" />
<link rel="stylesheet" type="text/css" media="all" href="css/responsive.css">
</head>
<body>
<img src="images/banner.jpg" width="100%" />
<section id="container">
<?php
include "../db.php";
$hallticket = $_REQUEST["uname"];
$query = mysql_query("SELECT * FROM results where Hall_Ticket_No='$hallticket'");
$row = mysql_fetch_array($query);
?>
<div id="title" align="center"><h3>Exam Results</h3></div>
<div id="tab">
<table align="center">
<tr><td><b>HallTicketNo</b></td><td> : <?php echo $row['HallTicketNo'];?></td></tr>
<tr><td><b>RNO</b></td><td> : <?php echo $row['RNO'];?></td></tr>
<tr><td><b>FirstName</b></td><td> : <?php echo $row['FirstName'];?></td></tr>
<tr><td><b>LastName</b></td><td> : <?php echo $row['LastName'];?></td></tr>
<tr><td><b>ClassID</b></td><td> : <?php echo $row['ClassID'];?></td></tr>
<tr><td><b>ClassName</b></td><td> : <?php echo $row['ClassName'];?>
<tr><td><b>ExamID</b></td><td> : <?php echo $row['ExamID'];?></td></tr>
<tr><td><b>ExamName</b></td><td> : <?php echo $row['ExamName'];?></td></tr>
<tr><td><b>ClassResult</b></td><td> : <?php echo $row['ClassResult'];?></td></tr>
<tr><td></td></tr>
</table>
<br>
<div id="sign" align="right"><img src="images/sign.png" height=100 width=80></div>
<br>
<center><input type="button" value="home" /></center>
</div>
</section>
</body>
</html>
<?php
}
?>
Than you
In index.php you are not starting session and not registering session id. That is why the if condition of your result.php is not executing.
In index.php do add this line.
<?php
session_start();
$_SESSION['id']= "1213"; //your id here
?>

Jquery Validation Engine not working in Chrome and Safari

I downloaded the Jquery Validation Engine from https://github.com/posabsolute/jQuery-Validation-Engine, it is working perfectly in IE and Firefox but it is not working on Chrome and Safari, the problem is that it does not matter if the fields are empty or invalid characters are entered, the form will always be submitted and since I'm using php to enter the data to a database obvioulsy the fields are entered as empty.
I am sure I included all needed scripts; have you read about any other member having issues with chrome and Safari using the plug in? I will really appreciate your help Pals.
Adding the code in edit (sorry friends):
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
<link rel="stylesheet" href="css/template.css" type="text/css"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
<script src="js/jquery-1.8.2.min.js" type="text/javascript">
</script>
<script src="js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8">
</script>
<script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8">
</script>
<script>
jQuery(document).ready(function(){
// binds form submission and fields to the validation engine
jQuery("#collect").validationEngine('attach');
});
</script>
</head>
<body onLoad="formReset()" onUnload="formReset()">
<script>
function formReset()
{
document.getElementById("collect").reset();
}
</script>
<div class="formholder">
<form id="collect" class="formular" method="post" action="insert.php">
<fieldset>
<label>
<input value="" data-prompt-position="topRight:0,20" class="validate[required,custom[onlyLetterSp]] text-input" type="text" name="nombre" />
</label>
<br/>
<label>
<input value="" class="validate[required,custom[email]] text-input" data-prompt-position="topRight:0,20" type="text" name="email" />
</label>
<br/>
<label>
<input value="" data-prompt-position="topRight:0,20" class="validate[required,custom[phone]] text-input" type="text" name="telefono" />
</label>
<br/>
<label>
<select style="height:35px; width:200px;" name="informacion" class="select" form="contact-form" type= "select">
<option value="option1">option1</option>
<option value="option2">option2</option>
<option value="option3">option3</option>
<option value="option4">option4</option>
<option value="option5">option5</option>
</select>
</label>
<input class="submit" type="submit" value= ""/>
</fieldset>
<hr/>
</form>
</div>
</body>
</html>
see this code
It is working now ...
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" />
<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<script>
jQuery(document).ready(function(){
// binds form submission and fields to the validation engine
jQuery("#collect").validationEngine('attach');
});
</script>
</head>
<body onLoad="formReset()" onUnload="formReset()">
<script>
function formReset()
{
document.getElementById("collect").reset();
}
</script>
<div class="formholder">
<form id="collect" class="formular" method="post" action="insert.php">
<fieldset>
<label>
<input value="" data-prompt-position="topRight:0,20" class="validate[required] text-input" type="text" name="nombre" />
</label>
<br/>
<label>
<input value="" class="validate[required] text-input" data-prompt-position="topRight:0,20" type="text" name="email" />
</label>
<br/>
<label>
<input value="" data-prompt-position="topRight:0,20" class="validate[required] text-input" type="text" name="telefono" />
</label>
<br/>
<label>
<select style="height:35px; width:200px;" name="informacion" class="select" form="contact-form" type= "select">
<option value="option1">option1</option>
<option value="option2">option2</option>
<option value="option3">option3</option>
<option value="option4">option4</option>
<option value="option5">option5</option>
</select>
</label>
<input class="submit" type="submit" value= "test"/>
</fieldset>
<hr/>
</form>
</div>
</body>
</html>

php/jquery-mobile: Second page not running validation on two page form

I'm new to php and am trying to make a very simple two page form. Any help or guidance would be very appreciated!
Problem:
The second page does not run error validation when coming to it from the first page.
Both pages run error validation correctly URL's entered directly
Setup:
Page 1 one is HTML. It POSTS to Page2.
Page 2 is php and the data from Page 1 is stored in an input field
Live example:
http://www.linplusg.com/page1.html
In IE the Page 2 URL after coming from Page 1 looks to be incorrect:
http://www.linplusg.com/page1.html#/page2.php
In FF and Chrome the URL looks fine but I think there's a flicker/refresh happening.
Does something else happen besides just opening the page when doing a POST to a page? Does something value get stored the new fields? Am I doing the form action wrong? Dazed and confused...
Thank you so much for any help or suggestions. I've been searching around for answers all night and my brain feels like jello. It seems like I'm missing something simple?!
Page1 Code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>
</title>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<link rel="stylesheet" href="css/my.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js">
</script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js">
</script>
<script>
$(document).ready(function(){
$("#initialForm").validate();
});
</script>
</head>
<body>
<!-- Home -->
<div data-role="page" id="page1">
<div data-role="content">
<form id="initialForm" method="post" action="page2.php">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-mini="true">
<label for="textinput3">
Zip Code
</label>
<input name="zip" id="zip" maxlength=5 value="" type="text" class="required" />
</fieldset>
</div>
<input type="submit" data-theme="e" value="Submit" />
</form>
</div>
</div>
</body>
</html>
Page 2 code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>
</title>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<link rel="stylesheet" href="css/my.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js">
</script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js">
</script>
<script>
$(document).ready(function(){
$("#fullForm").validate();
});
</script>
</head>
<body>
<!-- Home -->
<div data-role="page" id="page1">
<div data-role="content">
<form id="fullForm" method="get" action="">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-mini="true">
<input name="zip" id="zip" value="<?php echo $_POST["zip"]; ?>" type="" />
</fieldset>
</div>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-mini="true">
<label for="textinput3">
First Name
</label>
<input name="first_name" id="first_name" placeholder="" value="" type="text" class="required"/>
</fieldset>
</div>
<input type="submit" data-theme="e" value="Submit" />
</form>
</div>
</div>
</body>
</html>
To prevent this you need to specify data-ajax="false" in the form element in page1.
<form id="initialForm" method="post" action="page2.php" data-ajax="false">
see http://jquerymobile.com/test/docs/forms/forms-sample.html for more information.
Without the PHP code, I can just guess, but maybe it is because in the second form you have a method="get" instead of method="post", and in PHP you check the $_POST variable?
You could preserve the ajax transitions and still have your javascript execute on your second page by moving your script inside the div with the data-role "page".
See this answer here: https://stackoverflow.com/a/6428127/2066267

Trouble integrating jqtransform plugin with Cascade drop down

I have 3 select boxes that load dynamical based on the selection in each box. These work correctly before I try and style the page using the jqtransform plugin. I have tried to figure this out and have searched this site and the web with out finding a solution as to why the select menus do not populate at all if I use the jqtransform plugin. Any help would be greatly appreciated.
Original working code:
`<script language="JavaScript" src="myminiAJAX.js"></script>
<script language="JavaScript" src="functions.js"></script>
<script language="JavaScript">
function init() {
doAjax('man_list.php', '', 'populateComp', 'post', '1');
}
function showOutput(){
alert("This Is Your Model Id: "+getValue('manufacturer'));
}
$(function(){
$('form').jqTransform({imgPath:'jqtransformplugin/img/'});
});
</script>
<style>
#loading{
background:url('loader64.gif') no-repeat;
height: 63px;
}
</style>
</head>
<body onLoad="init();">
<p>
<form method="post" action="<?php echo $PHP_SELF;?>">
<b>System Type:</b> <select name="manufacturer" id="manufacturer" onChange="resetValues();doAjax('type_list.php', 'man='+getValue('manufacturer'), 'populateType', 'post', '1')">
<option value="">Please select:</option></select>
<br /><b>Type of Equipment: </b> <select name="printertype" id="printertype" disabled="disabled" onChange="doAjax('model_list.php', 'man='+getValue('manufacturer')+'&typ='+getValue('printertype'), 'populateModel', 'post', '1')">
<option value="">Please select:</option></select>
<br /><b>Equipment to be depoted out:</b> <select name="printermodel" id="printermodel" disabled="disabled" onChange="showOutput();">
<option value="">Please select:</option></select>
<br /><br /><input type="submit" name="action" value="Submit" />
Code After adding Jqtransform plugin:
<link rel="stylesheet" href="jqtransformplugin/jqtransform.css" type="text/css" media="all" />
<link rel="stylesheet" href="demo.css" type="text/css" media="all" />
<script language="JavaScript" src="myminiAJAX.js"></script>
<script language="JavaScript" src="functions.js"></script>
<script type="text/javascript" src="requiered/jquery.js" ></script>
<script type="text/javascript" src="jqtransformplugin/jquery.jqtransform.js" > </script>
Removed functions to shorten this post since they didn't change from the original code.
<body onLoad="init();">
<p>
<form method="post" action="<?php echo $PHP_SELF;?>">
<div class="rowElem"><b>System Type:</b> <select name="manufacturer" id="manufacturer" onChange="resetValues();doAjax('type_list.php', 'man='+getValue('manufacturer'), 'populateType', 'post', '1')">
<option value="">Please select:</option></select>
</div>
<div class="rowElem"><br /><b>Type of Equipment: </b> <select name="printertype" id="printertype" disabled="disabled" onChange="doAjax('model_list.php', 'man='+getValue('manufacturer')+'&typ='+getValue('printertype'), 'populateModel', 'post', '1')">
<option value="">Please select:</option></select>
</div>
<div class="rowElem"><br /><b>Equipment to be depoted out:</b> <select name="printermodel" id="printermodel" disabled="disabled" onChange="showOutput();">
<option value="">Please select:</option></select>
</div>
<div class="rowElem"><br /><br /><input type="submit" name="action" value="Submit" /> </div>
</p>
<div id="loading" style="display: none;"></div>
<div id="output"></div>

Java script stops after printing in php?

When the form is submit my jquery accordion stops working my file name is add.php here is its code
<?php require_once('database.php');?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<link rel="stylesheet" href="css/accordionTheme.css">
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.ui.core.js" type="text/javascript"></script>
<script src="js/jquery.ui.widget.js" type="text/javascript"></script>
<script src="js/jquery.ui.accordion.js" type="text/javascript"></script>
<script>
$(function() {
$("#myAccordion").accordion();
});
</script>
<head>
<body>
<div id="myAccordion"><!-- Start Accordion --->
<h2>
Add Student
</h2>
<div>
<form action="add.php" id="form1" method="get" >//here my form start
<p>Please add Student Data</p>
<label for="stname">Enter Student Name:</label>
<input name="stname" type="text" id="stname" size="37" />
<br /><br />
<label for="stclass">Enter Student Class :</label>
<select name="stclass">
<option>MPhil</option>
<option>M.Sc.</option>
</select>
<br />
<input name="Add" type="submit" id="Add" value="Add" />
</form>
<?php
//lets start submit data to database
if(isset($_GET['stname'])&& isset($_GET['stclass']))
{
$stname=$_GET['stname'];
$stclass=$_GET['stclass'];
if(mysql_query("insert into student(teacher_id,student_name,student_class) values ('1','$stname','$stclass')"));
{
print "<p>record added</p";
}
}
?>
</div>
<h2>
Add course
</h2>
<div></div>
<h2>
Add publication
</h2>
<div></div>
</body>
</html>
I am printing php inside body you can see recordadded when form is submitted.
The p tag you print using PHP is not closed, which is what makes JavaScript go crazy. Close it and it should work OK.

Categories