In the following code the Reset functionality is not working with this dropdown means onclick of Reset button textbox value get reset but the dropdown select is not reset to default value "select addvertize".
<form enctype="multipart/form-data" class="contact-form" name="deleteadvertize" id="deleteadvertize" action="" method="post">
<div class="row form-group">
<div class="col-xs-12">
<label>Select Advertize</label>
<div class="selector">
<?php
include 'config.php' ;
$result = mysql_query("select * from advertise");
echo '<select id="advt_id" name="advt_id" class="full-width selector">';
echo " <option value=''>Select One Advertize</option>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['advt_id'] ."'>" . $row['advt_title'] ."</option>";
}
echo "</select>"; ?>
</div>
</div>
</div>
<div align="center">
<button type="submit" class="btn-large">Submit</button>
<button type="reset" class="btn-large">Reset</button>
</div>
<form>
<div class="row form-group">
<div class="col-xs-12">
<label>Select Advertize</label>
<div class="selector">
<select id="advt_id" name="advt_id" class="full-width selector">
<option value=''>Select One Advertize</option>
<option value='1'>Select One </option>
</select>
</div>
</div>
</div>
<div align="center">
<button type="submit" class="btn-large">Submit</button>
<button type="reset" class="btn-large">Reset</button>
</div>
</form>
you need to you wrap your html in form tag
<form></form>
if still not work use jquery for this
$('select[name=advt_id] option').removeAttr('selected');
Reset works when you have <form></form> tag. Please check you have form tag or not ? if not the add.
Related
When I press on submit button on form in CodeIgniter,
if I am at XController/loadX
and my action is YController/loadY,
the URL becomes like Xcontroller/loadX/Ycontriller/loadY,
and I want it to be just YController/loadY.
<form name="SpecAccept"method="post"action="SpecialistController/loadDoctor">
<div class="form-group col-sm-12" id="myDiv" align="right">
<span><label>الولاية</label></span>
<select style="font-size:12px" class="form-control" id="state_name" onchange="change(this)">
<option>--- اختر الولاية ---</option>
<?php
foreach($states as $Object){
echo '<option value="'.$Object->StateID.'">'.$Object->StateName.'</option>';
}
?>
</select>
</div>
<div class="form-group col-sm-6" id="myDiv" align="right">
<span><label>المهنة</label></span>
<select style="font-size:12px" class="form-control" id="career_name" >
<option>--- اختر المهنة ---</option>
<?php
foreach($careers as $Object){
echo '<option value="'.$Object->CareerID.'">'.$Object->CareerName.'</option>';
}
?>
</select>
</div>
<div class="form-group col-sm-6" id="myDiv" align="right">
<span><label>المستشفى</label></span>
<select style="font-size:12px" class="form-control" id="hospitals" name="Hospitals" >
<option value="0" isSelected>اختر الولاية اولاً</option>
</select>
</div>
<div class="form-group col-sm-12">
<button type="sumbit">عرض</button>
</div>
</form>
what is the problem and how to fix it?
try to use javascript
<button type="button" onclick="Function_name();" >عرض</button>
then in a javascript you can do that
<script>
function Function_name(){
alert ('I AM HERE');
document.SpecAccept.submit();
}
</script>
that alert is to see if the button works and enter in the function.
if that not work try to change the type of form like this
<?php
$attributes = array(
'id' => 'SpecAccept',
'name' => 'SpecAccept',
'autocomplete' => 'off',
'enctype' => 'multipart/form-data',
);
echo form_open_multipart('SpecialistController/loadDoctor'); // this is the open <form>
?>
then for closed it replaces </form> tag for
<?php echo form_close();?>
First, you need to define base URL in config.php file like this
$config['base_url'] = 'http://localhost/projectfoldername/';
Now in form action URL
<form name="SpecAccept"method="post"action="<?php echo base_url('SpecialistController/loadDoctor'); ?> ">
I have two forms. After submitting first form it comes to a second form where i need to get values from first form. Here is the first part of form:
<?php $result2 = getProcessID();?>
<form class="formcss" method="post" action="create2.php" >
<div class="row">
<div class="small-8 large-8 columns">
<label>Process: <small style="color:red;">*</small>
<div class="multiselect">
<div class="selectBox">
<select onclick="showCheckboxes()" class="input input1 name">
<option>-- Select a process -- Add number of people reqired --</option>
</select>
<label class="tool tool1" for="name" style="top:-15px; margin-left:-14px; left:-207px; ">Choose process and number <br> of people required</label>
<div class="overSelect"></div>
</div>
<div class="scrollable" id="checkboxes">
<?php
while ($row = mysql_fetch_array($result2))
{
$row[0] = cleanOutputData($row[0]);
?>
<div class="row">
<div class="small-6 large-6 columns">
<label style="height: 38px;">
<input type='checkbox' style="width:20%;" name='process[]' id=<?php echo $row[0] ?> value=<?php echo $row[0] ?>/><?php echo $row[0] ?>
</label>
</div>
<div class="small-6 large-6 columns">
<label><input type='text'style="margin-left:50%; width:20%;" name='number[]'/>
</label>
</div>
</div>
<?php
}
mysql_free_result($result2);
?>
</div>
</div>
</label>
</div>
</div>
</form>
It seems fine to display the values in the second form except two problems:
1) Only half of the process is displayed
2) I can the number only for first 3 processes, but for other processes it stays an empty field.
Here is my second form:
$_SESSION['process'] = $_POST['process'];
$_SESSION['number'] = $_POST['number'];
$proc=$_SESSION['process'];
$len = count($proc); // getting length of an array
$num=$_SESSION['number'];
<form class="formcss" method="post" action="create.php#err" id="reportform" enctype="multipart/form-data">
<div id="project" class="small-9 large-9 columns">
<label style="font-size: 40px; margin-left:10%;">Project <?php echo $_SESSION["title"]; ?></label>
<label><?php for($y=0;$y<$len;$y++)
{
echo "Process: "."$proc[$y]"."<br />";
echo "People required: "."$num[$y]"."<br />";
?>
<ol>
<li class="placeholder" <?php if (isset($leader)) echo 'value="'.$leader.'"' ?>>Add people here</li>
</ol>
<?php
}
?>
</label>
<br><br><br>
<div class="row">
<input type = "submit" style="margin-left:300px; width:150px;" name ="submit" class="button" value = "Create Project" onclick="userSubmitted = true;"/>
</div>
</div>
</form>
As i said only half of the process is shown, for example, I have 'ANM KEY' process, and when i pass the value and display it on another form it displays only 'ANM'. Also I want to display number of people required for each process, but it works only for first three rows. So how i can get the wholename of the process, and display number of people required. Thank you!
I'm trying to populate a drop down from values in DB on the same page which is from input on the same page itself.
I have tried a few options on the forum but it did not help.
After hitting submit it goes to a next page which is blank.
I have tried onchange=AjaxFunction(); as suggested in one post, but i still get a blank page.
Any help is appreciated.
This is my form.php
<form action="connection.php" class="form-solid-blue" method="get">
<div class="title">
<h2></h2>
<h2>Tracking & Receiving</h2></div>
<div class="element-input<?php frmd_add_class("input2"); ?>">
<label class="title"></label>
<div class="item-cont">
<input class="small" type="text" name="store" placeholder="Store #"/>
<span class="icon-place"></span>
</div>
</div>
<div class="element-input<?php frmd_add_class("input"); ?>">
<label class="title"></label>
<div class="item-cont">
<input class="medium" type="text" name="userid" placeholder="UserId"/>
<span class="icon-place"></span>
</div>
</div>
<div class="element-input<?php frmd_add_class("input1"); ?>">
<label class="title"></label>
<div class="item-cont">
<input class="large" type="text" name="order" placeholder="Order Number"/>
<span class="icon-place"></span>
</div>
</div>
<div class="submit">
<input type="submit" value="Send"/>
</div>
<div class="element-separator">
<hr>
<h3 class="section-break-title">Tracking Numbers</h3>
</div>
<div class="element-multiple<?php frmd_add_class("multiple"); ?>">
<label class="title"></label>
<div class="item-cont">
<div class="large">
<select data-no-selected="Nothing selected" name="multiple[]" multiple="multiple">
<option value="option_1">option 1</option>
<option value="option_2">option 2</option>
<option value="option_3">option 3</option>
</select>
<span class="icon-place"></span>
</div>
</div>
</div>
<div class="submit">
<input type="submit" value="Submit"/>
</div>
</form>
This is the connection.php - Server side code
<?php
// Create connection to Oracle
$conn = oci_connect("XXXX", "xyxyx", "xyxyx");
if (!$conn) {
$m = oci_error();
echo $m['message'], "\n";
exit;
}
$query = "SELECT TRACKING_NUMBER FROM JC_SHIPPED_ORDER_TRACKING WHERE EXT_PURCHASE_ORDERS_ID = :order_bv";
$stid = oci_parse($conn, $query);
$order = $_GET['order'];
oci_bind_by_name($stid, ':order_bv', $order);
oci_execute($stid);
//Because order is a unique value I only expect one row
$row = oci_fetch_array($stid, OCI_ASSOC);
if (!$row) {
exit("The order " . $order . " is invalid. Please check and try again" );
}
$trackID = $row['TRACKING_NUMBER'];
echo "<form name=form1 method=POST action='form.php'>";
//echo "<select name='TRACKING_NUMBER' onchange=AjaxFunction();>";
while ($row = oci_fetch_array($stid)) {
echo "<option value=\"option_1\">" . $row['TRACKING_NUMBER'] . "</option>";
}
echo "</select>";
//echo ("The order " . $order . " is valid.");
oci_free_statement($stid);
oci_close($conn);
?>
This is the best I can do with the information provided.
in form.php
<select data-no-selected="Nothing selected" name="multiple[]" multiple="multiple">
<?php require 'path to connection.php'; ?>
</select>
oh and remove these from connection.php
echo "<form name=form1 method=POST action='form.php'>";
echo "</select>";
This is an image of how the page looks like,
The 2 big blue buttons at the top are buttons that represent a value from the database. The main function of this button is to help the user to fill in the form in a convenient way leaving only the "Description" to be filled in.
This is my code for the page,
<div class="bodycontainer">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">My Records</h3>
</div>
<div class="panel-body">
<?php
require 'dbfunction.php';
$con = getDbConnect();
$day = date("l");
if (mysqli_connect_errno($con)) {
"Failed to connect to MySQL: " . mysqli_connect_error();
} else {
$result = mysqli_query($con, "SELECT * FROM timetableschedule WHERE day='" . $day . "'");
while ($schedule = mysqli_fetch_array($result)) {
?>
<div class="col-md-4">
<div class="admininfobox">
<a class="btn btn-primary">
<?php
echo "<br/>";
echo $schedule['academicInstitution'] . "<br />";
echo $schedule['startTime'] . "-" . $schedule['endTime'] . "hrs<br />";
echo "<br/>";
?>
</a>
</div>
</div>
<?php
}
mysqli_close($con);
}
?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Record Activity</div>
<div class="panel-body">
<form name="Create New Admin" class="form-horizontal" method="post" action="handlerecord.php">
<div class="form-group">
<div class="col-sm-4">
<label>Academic Institution</label>
<input list="AcadInst" type="text" class="form-control" placeholder="Institution Name" name="academicInstitution">
<datalist id="AcadInst">
<option value="Singapore Polytechnic (SP)">
<option value="Ngee Ann Polytechnic (NP)">
<option value="Temasek Polytechnic (TP)">
<option value="Republic Polytechnic (RP)">
<option value="Nanyang Polytechnic (NYP)">
<option value="Others (Please specify)">
</datalist>
</div>
<div class="col-sm-4">
<label>Level of Teaching</label>
<input list="LvTeaching" type="text" class="form-control" placeholder="Teaching Stage" name="levelofteaching">
<datalist id="LvTeaching">
<option value="Undergraduate Teaching">
<option value="Postgraduate Teaching">
<option value="Continuing Education">
<option value="Others (Please specify)">
</datalist>
</div>
<div class="col-sm-4">
<label>Type of Teaching</label>
<input list="TyTeaching" type="text" class="form-control" placeholder="Teaching Type" name="typeofteaching">
<datalist id="TyTeaching">
<option value="Clinical Teaching">
<option value="Academic Teaching">
<option value="Talk">
<option value="Others (Please specify)">
</datalist>
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label for="startdate">Start Time</label>
<input type="text" class="form-control" placeholder="Select Time" name="starttime">
</div>
<div class="col-sm-4">
<label for="enddate">End Time</label>
<input type="text" class="form-control" placeholder="Select Time" name="endtime">
</div>
<div class="col-sm-4">
<label for="enddate">Description</label>
<input type="text" class="form-control" placeholder="Optional" name="Description">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<input type="submit" value="Add" class="btn btn-primary">
</input>
</div>
</div>
</form>
</div>
</div>
An overview of the database,
I am not sure on how to code it. Like Once the user click onto the button, the button goes through the database and input the data accordingly into the form ready for the user to submit.
My suggestion is to create an AJAX request on click.
Create a page loadFormData.php
Accept key data to search in database. For eg: id. Then search in database with this key and get the results. Finally encode this to json (json_encode()) and echo the result.
When the user clicks on the button, trigger an ajax (Javascript) function and send the key values to the loadFormData.php
From the returned json result, extract institution name, start time, end time etc and fill this to form fields using JavaScript
$("#blueButton").click(function() {
$.ajax({
type: "GET",
url: "loadFormData.php",
dataType: "json",
success : function(data) {
// extract each item from the variable 'data'
}
});
});
You should create a form and use action to state the method of entering the values that you want.
For example
http://www.w3schools.com/php/php_forms.asp
You can use this to enter the data easily.
I've looked all over the place and it seems that people only want to open a lightbox AFTER submitting a form. I however want to submit the form FROM a lightbox. All my code works until I put the form into a lightbox so I'm wondering if this is even possible.
Form submit code (PHP):
if(isset($_POST['updatemain'])) {
$company = $_POST['conameu'];
$vault = $_POST['vnameu'];
$q = "UPDATE siteinformation SET SiteName = :company, VaultName = :vault";
$query = $db->prepare($q);
$results = $query->execute(array(
":company" => $company,
":vault" => $vault
));
header('Location: vault.php');
}
Form in the lightbox code:
<div class="backdrop"></div>
<div class="box"><div class="close"><img src="images/close.png" /></div>
<fieldset>
<legend>Pick a Section to Work on</legend>
<div id="prompt">Select a Section:</div>
<div id="answer">
<select id="sectionchange">
<option value="main">Main Titles</option>
<option value="organ">Emergency Organizations</option>
<option value="number">Common Numbers</option>
<option value="website">Common Websites</option>
<option value="quicklink">Quick Links</option>
</select>
</div>
</fieldset>
<div id="mainsection">
<form id="updatemain" action="" method="post">
<fieldset>
<legend><strong>Main Title Information</strong></legend>
<div id="prompt">Client Company Name:</div><div id="answer"><input type="text" name="conameu" id="conameu" /></div>
<div id="prompt">Web Tool Name:</div><div id="answer"><input type="text" name="vnameu" id="vnameu" /></div>
<div id="prompt"><input type="submit" id="updatemain" value="Update Information" /></div>
</fieldset>
</form>
</div>
</div>
</div>
Like I said, this works FINE until it is in the light box so I'm kind of stumped at this point.
Any ideas?
Thanks in advance for your time!
Per the comment section:
Add a name attribute with the value updatemain to your submit button.
Without this, PHP will not have a POST value $_POST['updatemain'] set, so the first if statement will always be false.
Updated to reflect that the "name" must be present in the submit button for this to work, even though for whatever reason it didnt need to be before. Thanks again #andbeyond
<div class="backdrop"></div>
<div class="box"><div class="close"><img src="images/close.png" /></div>
<fieldset>
<legend>Pick a Section to Work on</legend>
<div id="prompt">Select a Section:</div>
<div id="answer">
<select id="sectionchange">
<option value="main">Main Titles</option>
<option value="organ">Emergency Organizations</option>
<option value="number">Common Numbers</option>
<option value="website">Common Websites</option>
<option value="quicklink">Quick Links</option>
</select>
</div>
</fieldset>
<div id="mainsection">
<form id="updatemain" action="" method="post">
<fieldset>
<legend><strong>Main Title Information</strong></legend>
<div id="prompt">Client Company Name:</div><div id="answer"><input type="text" name="conameu" id="conameu" /></div>
<div id="prompt">Web Tool Name:</div><div id="answer"><input type="text" name="vnameu" id="vnameu" /></div>
<div id="prompt"><input type="submit" id="updatemain" name="updatemain" value="Update Information" /></div>
</fieldset>
</form>
</div>
</div>
</div>