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>
Related
<div class="submit-group">
<button class="btn btn-green btn-large btn-full upper btn-book-ajax" type="submit" name="submit">
Book Now
<i class="fa fa-spinner fa-spin hide"></i>
</button>
<input style="display:none;" type="submit" class="btn btn-default btn-send-message" data-id="9278" name="st_send_message" value="Send message">
</div>
the button class="btn btn-green btn-large btn-full upper btn-book-ajax" has the same function have to " add to cart " button in woo commerce
I am looking to disable add to cart redirection after submitting
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>
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>
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;
}
}
i have two buttons of type submit in my view:
<button type="submit" class="btn btn-default btn-xs" name="Excel">
<span class="glyphicon glyphicon-download-alt"></span> Download as Excel
</button>
<button type="submit" class="btn btn-default btn-xs" name="Resume">
<span class="glyphicon glyphicon-download-alt"></span> Download Resume
</button>
and controller:
if ($this->input->post('Resume')) {
echo "Resume Clicked";
}
if ($this->input->post('Excel')) {
echo "Excel Clicked";
}
i would like to know that which button has submitted the form for that i have written the above code..but i am not getting any echo after clicking any of the button..
i don't want to use here:
<input type='submit' name='excel' value='Excel'/>
<input type='submit' name='excel' value='Excel'/>
as it works with the type 'input' i would like to use button of type submit
Add a value to the button, ie:
<button type="submit" class="btn btn-default btn-xs" name="Resume" value="true">
<span class="glyphicon glyphicon-download-alt"></span> Download Resume
</button>
You will have a $_POST['Resume'] with value "true" in your backend code.
Ofcourse something like: name="buttonName" value="Excel" and another button with name="buttonName" value="Resume" would make have a $_POST['buttonName'] with its value either being 'Excel' or 'Resume'.