show the html div id and rearrange the rest - php

i have 5 divs , with different id's. I want to make a step formation like if i get the value(from url) measures
example:
, it shows me the first div with id measures and rearrange the rest of the divs including fabrics which exists before measures div and so on
Then after, when i click the Next button it shows me the rearranged div one by one.
I have done this whole code using php and jquery.
Is it possible to do this using jquery or javascript or anything, Please help me to fix this.
Thanks in advance.
my Code is
var navListItems = $('div.setup-panel div a'),
allWells = $('.setup-content'),
allNextBtn = $('.nextBtn'),
allPrevBtn = $('.prevBtn');
allWells.hide();
navListItems.click(function (e) {
e.preventDefault();
var $target = $($(this).attr('href')),
$item = $(this);
if (!$item.hasClass('disabled')) {
navListItems.removeClass('btn-primary').addClass('btn-success');
$item.addClass('btn-primary');
allWells.hide();
$target.show();
$target.find('input:eq(0)').focus();
}
});
allPrevBtn.click(function(){
var curStep = $(this).closest(".setup-content"),
curStepBtn = curStep.attr("id"),
prevStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().prev().children("a");
prevStepWizard.removeAttr('disabled').trigger('click');
});
allNextBtn.click(function(){
var curStep = $(this).closest(".setup-content"),
curStepBtn = curStep.attr("id"),
nextStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().next().children("a"),
curInputs = curStep.find("input[type='text'],input[type='url']"),
isValid = permission;
$(".form-group").removeClass("has-error");
for(var i=0; i<curInputs.length; i++){
if (!curInputs[i].validity.valid){
isValid = false;
$(curInputs[i]).closest(".form-group").addClass("has-error");
}
}
if (isValid)
nextStepWizard.removeAttr('disabled').trigger('click');
});
$('div.setup-panel div a.btn-primary').trigger('click');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row setup-content" id="step-1"> // i will change it's id to fabrics
<button class="btn btn-primary nextBtn btn-lg pull-right btn-xs fabric_button" id="fabric"> Next </button>
</div>
<div class="row setup-content" id="step-2" > // i will change it's id to patterns
<button class="btn btn-primary nextBtn btn-lg pull-right btn-xs" type="button" id="pattern" >Next</button>
</div>
<div class="row setup-content" id="step-3" > // i will change it's id to measures
<button class="btn btn-primary nextBtn btn-lg pull-right btn-xs" type="button" id="pattern" >Next</button>
</div>
<div class="row setup-content" id="step-4" > // i will change it's id to Pair
<button class="btn btn-primary nextBtn btn-lg pull-right btn-xs" type="button" id="pattern" >Next</button>
</div>
<div class="row setup-content" id="step-5" > // i will change it's id to total
<button class="btn btn-primary nextBtn btn-lg pull-right btn-xs" type="button" id="pattern" >Next</button>
</div>

Related

I want to disable the button by checking allover Database condition

I am checking the time for which the doctor is appointed and if the doctor is appointed then we have to disable the Button for that specific time for 3 months. My condition is not satisfying the code and Foreach is not working properly
I have tried using eloquent but the code is not matching the condition
Controller
public function doctor(){
$data['page_title'] = 'Doctor';
$doctors = Doctor::all();
$data['doctors'] = WebDoctorDetails::all();
return view('frontend.doctor',['doctors'=>$doctors])-
>withData((object)$data);
}
HTML Code
<div>
<div class="main_div">
<div class="buttons">
#foreach($doctors as $doctor)
#if($doctor->transaction_id != NULL && $doctor->plan == "90" && $doctor->cabin == "Cabin 1" && $doctor->day =="Friday" && $doctor->time == "8.00 - 10.00")
<script>
$('#a').attr("disabled", true);
setTimeout(function() { enableSubmit('#a') }, 7776000);
</script>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" id="a" data-target="#myModal">8.00 - 10.00</button>
#else
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">8.00 - 10.00</button>
#endif
#endforeach
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal1">10.30 - 12.30</button>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal2">1.00 - 3.00</button>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal3">3.30 - 5.30</button>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal4">6.00 - 8.00</button>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal5">8.30 - 10.30</button>
</div>
</div>
</div>
I want my output like this : https://ibb.co/5FNTVBf
But I am Getting This : https://ibb.co/MsTqSy4
just add disabled attribute to button if condition match
#php($found = false)
#foreach($doctors as $doctor)
#if($doctor->transaction_id != NULL && $doctor->plan == "90" && $doctor->cabin == "Cabin 1" && $doctor->day =="Friday" && $doctor->time == "8.00 - 10.00")
#php($found = true)
#endif
#endforeach
#if($found)
<button type="button" class="btn btn-info btn-lg matchButton" data-toggle="modal" data-target="#myModal" disabled>8.00 - 10.00</button>
#else
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">8.00 - 10.00</button>
#endif
then to enable it after 7776000 milliseconds ,
<script>
$(document).ready(function(){
setTimeout(function(){
$('.matchButton').removeAttr('disabled');
}, 7776000);
});
</script>

how to save previous page clikable url in database using php?

i have following div in project. after clicking on "request for demo" button , it will redirect to next window to registration form (link is mentioned in javascript function). i want to save relevant div id in database after clicking on button and save register.
following is my html and javascript
<div class="row">
<div class="col-md-4 col-sm-6 pos-vertical">
<span><b>Supermarkets, Fruits & Vegetables</b></span>
<hr>
<p>Uninterrupted fast billing, inventory control, CRM & Loyalty programs makes your shoppers happier</p>
<button type="button" class="btn btn-default" id="dwmld-btn">Free Download</button>
<!--<button type="button" onclick="openWin()" class="btn btn-default" id="demo-btn" data-toggle="modal" data-target="#demoModal">Request for Demo</button>-->
<button type="button" onclick="openWin()" class="modalBtn btn btn-default" id="Supermarkets, Fruits and Vegetables" >Request for Demo</button>
</div>
<div class="col-md-4 col-sm-6 pos-vertical">
<span><b>Grocery & Departmental Stores</b></span>
<hr>
<p>POS for grocery, departmental store, hypermarket and convenience store with GSmartPOS</p>
<button type="button" class="btn btn-default" id="dwmld-btn">Free Download</button>
<button type="button" onclick="openWin()" class="modalBtn btn btn-default" id="Grocery and Departmental Stores" >Request for Demo</button>
</div>
<div class="col-md-4 col-sm-6 pos-vertical">
<span><b>Pharmacy, Medical Shop POS</b></span>
<hr>
<p>Prefilled drug index, update stock position and bill from Day One. Manage batches and expiry with ease</p>
<button type="button" class="btn btn-default" id="dwmld-btn">Free Download</button>
<button type="button" onclick="openWin()" class="modalBtn btn btn-default" id="Pharmacy Medical Shop POS" >Request for Demo</button>
</div>
<br>
<div class="col-md-4 col-sm-6 pos-vertical">
<span><b>Apparel & Footwear</b></span>
<hr>
<p>POS Features like matrix-inventory, non-moving stock analysis, can help keep inventory latest and fashionable</p>
<button type="button" class="btn btn-default" id="dwmld-btn">Free Download</button>
<button type="button" onclick="openWin()" class="modalBtn btn btn-default" id="Apparel and Footwear" >Request for Demo</button>
</div>
<div class="col-md-4 col-sm-6 pos-vertical">
<span><b>Electrical & Electronics POS</b></span>
<hr>
<p>Perfect solution to manage serialized inventory for mobile, computer electrical and electronics shops</p>
<button type="button" class="btn btn-default" id="dwmld-btn">Free Download</button>
<button type="button" onclick="openWin()" class="modalBtn btn btn-default" id="Electrical and Electronics POS" >Request for Demo</button>
</div>
<div class="col-md-4 col-sm-6 pos-vertical">
<span><b>Fashion Jewellery Shop</b></span>
<hr>
<p>An integrated, modular & scalable POS for furniture, glass & crockeries, opticals, music, toys & baby shop retail</p>
<button type="button" class="btn btn-default" id="dwmld-btn">Free Download</button>
<button type="button" onclick="openWin()" class="modalBtn btn btn-default" id="Fashion Jewellery Shop" >Request for Demo</button>
</div>
</div>
following function is called on each div button,
<script>
function openWin() {
window.open("register.php");
}
</script>
after clicking on each div button following form will be open in new window,
<div class="register">
<div class="container">
<div class="row main">
<div class="main-register main-center">
<form class="" method="post" id="contact-form">
<div class="form-group">
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon" id="register-icon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="name" placeholder="Enter your Name"/>
</div>
</div>
</div>
<div class="form-group">
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon" id="register-icon"><i class="fa fa-envelope fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="email" placeholder="Enter your Email"/>
</div>
</div>
</div>
<div class="form-group">
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon" id="register-icon"><i class="fa fa-phone fa" aria-hidden="true"></i></span>
<input type="text" class="form-control" id="contact_no" placeholder="Enter your contact number"/>
</div>
</div>
</div>
<input type="hidden" id="requestType">
<div class="form-group ">
<button class="btn btn-primary btn-lg btn-block register-button submit">Register</a>
</div>
</form>
<span class="success" style="display:none">Thank You for Register with us.</span>
</div>
</div>
</div>
</div>
form will be save using ajax and php
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" >
$(function() {
$(".modalBtn").click(function(){
var formName = $(this).attr("id");
$('#requestType').val(formName);
$('.success').hide();
$('.error').hide();
$('#contact-form').show();
$("#demoModal").modal();
});
$(".submit").click(function() {
var name = $("#name").val();
var requestType = $('#requestType').val();
var contact_no = $("#contact_no").val();
var email = $("#email").val();
//alert(requestType);
var dataString = 'name='+ name + '&contact_no=' + contact_no + '&email=' + email+ '&requestType=' + requestType;
if(name=='' || contact_no=='' || email=='')
{
$('.success').fadeOut(200).hide();
$('.error').show();
}
else
{
$.ajax({
type: "POST",
url: "register.php",
data: dataString,
success: function(){
$('.success').fadeIn(200).show();
$('.error').fadeOut(200).hide();
$('#contact-form').hide();
}
});
}
return false;
});
});
</script>
Php code to insert data is,
<?php
require('connection.php');
if($_POST) {
$id = $_POST['regid'];
$name = $_POST['name'];
$contact_no = $_POST['contact_no'];
$email = $_POST['email'];
$requestType = $_POST['requestType'];
if ($id == '') {
$sql = "INSERT INTO registration(name,contact_no,email,requestType) VALUES ".
"('".$name."', '".$contact_no."', '".$email."','".$requestType."')";
}
$query_result = mysql_query( $sql );
if(!$query_result ) {
echo 'Could not enter data: ' . mysql_error();
} else {
//header("Location: lead-view.php?s=Y");
$successMsg = 'Record instered successfully';
}
}
?>
i want save those div id as in url after submitting form of relevant dive click button. url will be save in "requestType" field in database. please help.
You can make use of sessionStorage for passing the requestType value.
https://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/
While calling openWin() pass the div value to it. For example:
<button type="button" onclick="openWin('abc')" class="modalBtn btn btn-default" id="Supermarkets, Fruits and Vegetables" >Request for Demo</button>
Then save this value in sessionStorage as follows:
function openWin(div_value) {
sessionStorage.setItem("registerType", div_value);
window.open("register.php");
}
You can retrieve this variable in register.php:
var registerType = sessionStorage.getItem("registerType");
Add this value to the hidden input control in register form and save it to database.
<input type="hidden" id="requestType">

How to get values from a button

I have a form which goes through three steps. In step 2, I am asking the user to select a speciality by clicking the corresponding button. If they click a button, they should move to the 3rd and final step.
Here is the button code:
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="hair_stylist" >HAIR STYLIST</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="cosmetologist" >COSMETOLOGIST</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="makeup_artist" >MAKEUP ARTIST</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="barber" >BARBER</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="esthetician" >ESTHETICIAN</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="nail_technitian" >NAIL TECHNITIAN</button>
I don't think name will work here. Is there anything that can be done with data-*? How can I send and grab this value in PHP when the form is submitted?
Having a name is fine and necessary.
There are two problems.
You need actually have a value in order to send a value
You need the button to be a submit button in order to submit the form
Such:
<button
class="btn btn-primary nextBtn btn-proffessional"
type="submit"
name="profession"
value="hair_stylist">
Hair Stylist
</button>
Then in PHP you can simply:
do_something_with($_POST["profession"]);
You can also use jquery Post function for this.
First little bit change your html code. Put your values inside id of your buttons
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="hair_stylist" id="HAIR STYLIST">HAIR STYLIST</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="cosmetologist" id="COSMETOLOGIST">COSMETOLOGIST</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="makeup_artist" id="MAKEUP ARTIST">MAKEUP ARTIST</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="barber" id="BARBER" >BARBER</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="esthetician" id="ESTHETICIAN" >ESTHETICIAN</button>
<button class="btn btn-primary nextBtn btn-proffessional "
type="button" name="nail_technitian" id="NAIL TECHNITIAN" >NAIL TECHNITIAN</button>
Then Some jquery code here:
$(document).ready(function () {
$('.nextBtn').on('click', function () {
$.post("NewPage.php",
{value: this.id
});
});
});
After clicking button. That particular button will be accessed by its class then it sends data to NewPage.php (You have to make new php page) where you can access value by POST array.
NewPage.php
If(isset($_POST['value']))
{
//Do your process here
}
Use the value parm.
Example:
<button class="btn btn-primary nextBtn btn-proffessional " type="button" name="hair_stylist" value="HAIR STYLIST">HAIR STYLIST</button>

How to add (or subtract) a value by pressing the submit button PHP

I have the following code=>
<button class="btn btn-lg btn-warning text-center but-width" id="first" name="geri" type="submit" value="<?php ?>">BACK</button>
<button class="btn btn-lg btn-warning text-center but-width" id="second" name="ileri" type="submit" value="<?php ?>">FORWARD</button>
These buttons submit the form to the same page. At the top of the page I have variable $t which is initialized at value '0' and is followed by the codes=>
$t=0;
if( $this->input->post('ileri') ) { $t=$t+1;} // Back button was pressed;
if( $this->input->post('geri') ) { $t=$t-1;} // Forward button was pressed;
Now as I press forward I want to increase $t and when I press back I want to decrease it. But because of the declaration at the top ($t=0;) it goes as far as '1' with 'forward' and as back as '0' with 'back' buttons. Can anyone think of a way of getting over this problem.
Thank you...
Add a hidden input, and store $t there. This gets posted upon submit:
<?php
$t = $this->input->post('t');
if (!$t) $t = 0;
if( $this->input->post('ileri') ) { $t=$t+1;} // Back button was pressed;
if( $this->input->post('geri') ) { $t=$t-1;} // Forward button was pressed;
?>
<input name="t" type="hidden" value="<?=$t ?>">
<button class="btn btn-lg btn-warning text-center but-width" id="first" name="geri" type="submit" value="submit">BACK</button>
<button class="btn btn-lg btn-warning text-center but-width" id="second" name="ileri" type="submit" value="submit">FORWARD</button>
You could use url parameter. Get instead of post. so that it stores the current value of variable $t i.e.
if (isset($_GET['t']))
{
$t = $_GET['t'];
}
else
{
$t = 0;
}
Something like that could be of some help
If you want to know what button makes the submit you need to change the buttons
<button class="btn btn-lg btn-warning text-center but-width" id="first" name="geri" type="submit" value="<?php ?>">BACK</button>
<button class="btn btn-lg btn-warning text-center but-width" id="second" name="ileri" type="submit" value="<?php ?>">FORWARD</button>
to
<button class="btn btn-lg btn-warning text-center but-width" id="first" name="s_button" type="submit" value="geri">BACK</button>
<button class="btn btn-lg btn-warning text-center but-width" id="second" name="s_button" type="submit" value="ileri">FORWARD</button>
in your controller
$button_s = $this->input->post('s_button');
if( isset($button_s)){
switch($button_s){
case 'geri':
//do somthing
break;
case 'ileri':
//do somthing
break;
}
}

Bootstrap button, how to click multiple times

I have a counter which adds number of rows to a table based on what the counter is. I have one button that increase the counter every time its clicked, but it only works one time.
php:
if (isset($_REQUEST['Addmore'])) {
$NoOfUsers++;
<form action="addstudent.php">
<th>
<button type="submit" class="btn btn-default btn-sm spoiler-trigger pull-right" aria-label="Left Align" name="Addmore" title="Add Row">
<span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"> </span>
</button>
</th>
</form>
php
<?php
session_start();
if (isset($_REQUEST['Addmore'])) {
?><button class="btn btn-default"><?php
echo $_SESSION['NoOfUsers'] ? ++$_SESSION['NoOfUsers'] : $_SESSION['NoOfUsers']=1;
?></button><?php
}
or JavaScript
<button id="counter" class="btn btn-default">0</button>
<script>
$('#counter').on('click',function(){$( this ).html(1 * $( this ).html() + 1)});
</script>

Categories