I am using modal window to post the the values to the controller .
<form action="<?php echo base_url();?>Users/sms/" id="form" method="post" class="form-horizontal" enctype="multipart/form-data">
buttons
<button type="button" id="custom" class="btn btn-warning" disabled="disabled">
Custom Msg
</button>
<button type="button" id="initial" class="btn btn-primary">
Initial
</button>
no response in my screen. i cannot able find the error. in popup window showing nothing. when i click the button no response. suggestion please
Type should be submit instead of button to post the data.
Related
I'm a bit confuse on this form behaviour, I can get the second form but the first form is null. Here is my form codes:
<div class="modal-body">
<form action="{{ route('payroll',$data->id) }}" method="get" id="duadua">
</form>
<form action="{{ route('payroll',$data->id) }}" method="get" id="payrollForm">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button id="payrollSubmit" type="button" class="btn btn-primary">
{{ __('Process') }}
</button>
</div>
<script type="text/javascript">
$('document').ready(function(){
$("#payrollSubmit").click(function(){
var isi = document.getElementById('payrollForm');
console.log(isi);
});
});
</script>
I can get value of second form like this:
Meanwhile when I change to call first form (duadua) it returs null, like this:
I have no Idea why only second form can be called, while first form returns null.
I'm trying to figure out how to disable the submit button if the user is not part of a specific group, but I can only find examples for after the form is submitted. Can someone help out?
<button class="btn btn-primary" type="button" id="SubmitFileButton"> Submit </button>
you get grup data in this page.you can get group data in this page then after you can write php condition in this button.
<button class="btn btn-primary" type="button" id="SubmitFileButton" <?php if(not part of group) disable; ?>> Submit </button>
<button class="btn btn-primary" type="button" id="SubmitFileButton" disabled="disabled">
Submit
</button>
I assume that this is what you're looking for.
I'm currently having an issue with posting method directly on submit buttons. What I need to do is to put two submit buttons in the same form. I've searched a little and found the html "formaction" method. The problem is that on one page, it is working just fine, but not on the other page.
So, this down here is my code that works:
<form action="" method="POST">
{{ csrf_field() }}
<input type="hidden" name="id" value="$id">
<button type="submit" formaction="{{route('remove')}}">
<i class="fa fa-check-circle" aria-hidden="true"></i>
</button>
</form>
And that one don't:
<form method="POST">
{{csrf_field()}}
<input type="hidden" name="id" value="{{$q->id}}">
<button type="button" formaction="{{route('remove')}}">
<i class="fa fa-trash" aria-hidden="true" style="font-size: 20px; color: red;"></i>
</button>
</form>
Someone has any idea why that is happening? I'm searching for this for a while now, but I just found dead ends.
suggestion
add a name="" for each button, and use $_POST["name_of_submit"] to process the form submission. example
//1st button
<button type="submit" name="submit1" formaction="{{route('remove')}}">
//2nd button
<button type="submit" name="submit2" formaction="{{route('remove')}}">
if (isset($_POST['submit1'])){
//do something
}
if (isset($_POST['submit2'])){
//do something else
}
I have a simple php form and it's action link is another php file/page.
I am trying to show a popup before sending the PHP form to it's action page.
I tried onsubmit , onclick but nothing is working.
this is my form
<form method="post" action="/actions.php/" data-js-validate="true" data-js-highlight-state-msg="true" data-js-show-valid-msg="true">
<input type="text" name="amount[]" placeholder="Amount" class="inputChangeVal" data-js-input-type="number" />
<button class="btn" type="submit" name="confirm" >Pay Now</button>
</form>
this form send the amount value to the actions.php
but before sending this I want to show a poup that shows 'Edit' , 'Continue' with this message "Your about to make a online payment. Click 'Edit' to review the data before proceeding or click 'Continue' to confirm the details for payment."
if user clicks 'Edit' form submission should be stopped and popup should be closed.
if user clicks 'Continue' form should submit the data to the action.php
I tried:
<button class="btn" type="submit" name="confirm" onclick="return foo();">Pay Now</button>
<script>
jQuery( document ).ready(function() {
function foo()
{
alert("Submit button clicked!");
return true;
}
});
</script>
this does not work..
I tried
<form method="post" action="/actions.php/" data-js-validate="true" data-js-highlight-state-msg="true" data-js-show-valid-msg="true" onsubmit="return foo()">
also not working..
Both just go to the actions.php
how can I show the popup and then send the form based on the selection?
Basically the best way I see to achieve this is to use the bootstrap modal, so what you need to do is to stop the form from submission when the button is clicked, then show the bootstrap modal using jquery , then you form will have two buttons one the edit which will then have the data-dismiss="modal" which will just close the modal and show back the form, then the continue button when clicked you will just force the form to submit using jquery as well with $('form').submit(); this tells the form to submit to the form action.
$('document').ready(function(){
$('#payBtn').on('click',function(e){
e.preventDefault();
$('#myModal').modal('toggle');
});
$('#continuebtn').on('click',function(){
$('form').submit();
});
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<form method="post" action="/actions.php/" data-js-validate="true" data-js-highlight-state-msg="true" data-js-show-valid-msg="true">
<input type="text" name="amount[]" placeholder="Amount" class="inputChangeVal" data-js-input-type="number" />
<button class="btn" type="submit" name="confirm" id="payBtn">Pay Now</button>
</form>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Proccess Payment</h4>
</div>
<div class="modal-body">
"Your about to make a online payment. Click 'Edit' to review the data before proceeding or click 'Continue' to confirm the details for payment."
<button class="btn btn-default" data-dismiss="modal">Edit</button>
<button class="btn btn-primary" id="continuebtn">Continue</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
You could achieve your goal with using javascript alerts. Your php will not call the other php directly, but a javascript method, which then shows an alert with 2 buttons. Look into https://www.w3schools.com/js/js_popup.asp as it probably describes it better than me.
Best wishes,
Essi
Please check this its working now. You don't need document.ready just simply add to js file or in tag!
function foo()
{
if(confirm('You\'re about to make a online payment. Click "Cancel" to review the data before proceeding or click "Ok" to confirm the details for payment.'))
{
alert("confirm ok");
document.getElementById("form_id").submit();// Form submission
}
else {
return false;
}
}
<form method="post" id="form_id" action="/actions.php/" data-js-validate="true" data-js-highlight-state-msg="true" data-js-show-valid-msg="true">
<input type="text" name="amount[]" placeholder="Amount" class="inputChangeVal" data-js-input-type="number" />
<button class="btn" type="submit" name="confirm" onclick="foo();" >Pay Now</button>
</form>
I want to pass a variable but for that I need to create a form. But I am using JavaScript to open the next page (that is a block page)
but I want to pass the method="post" directly in the button and not in the form, because it does not recognise the code.
Here is an example:
<form action="" method="post">
<button onclick="document.getElementById('id144').style.display='block'" class="btn btn-warning">
Editar nome grupo
</button>
</form>
What I want:
<button //pass method = post here onclick="document.getElementById('id144').style.display='block'" class="btn btn-warning">
Editar nome grupo
</button>
<form action="" id="formname" method="post">
</form>
<button onclick="document.getElementById('formname').submit();document.getElementById('id144').style.display='block';" class="btn btn-warning">Editar nome grupo</button>
Set form id.