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.
Related
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.
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>
I'm working on a web page where a user will be allowed to add or edit a feedback for a place. If the person already gave the place a feedback, he/she will be shown an Edit Review button otherwise, the user will be shown an Add Review button.
In my feedback table in my database, I have a places_id and users_id column. Here's my query in PHP (Assuming that $id and $places_id have values):
<?php
$query5 = mysql_query("SELECT * FROM feedback WHERE user_id = '$id' AND places_id = '$places_id'");
$row5 = mysql_fetch_array($query5);
if($row5['user_id'] != $id){
?>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span> Back</button>
<button class="btn btn-primary" type="submit" name="submit">Review</button>
<?php }else{ ?>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span> Back</button>
<button class="btn btn-primary" type="submit" name="submit">Edit Review</button>
<?php } ?>
I was thinking that if the query did not return a result where the given user_id is not equal to the user_id in the result, it would let me do my if-else condition. However if there is a feedback for a current place, it displays the button found in the else statement.
What do you think is the problem and why is the if condition not working?
I also tried if(mysql_num_rows($query5)==0) but it's also not working.
I would always do:
<?php
$query5 = mysql_query("SELECT * FROM feedback WHERE user_id = '$id' AND places_id = '$places_id'");
if ($row5 = mysql_fetch_array($query5)) {
?>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span> Back</button>
<button class="btn btn-primary" type="submit" name="submit">Edit Review</button>
<?php }else{ ?>
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span> Back</button>
<button class="btn btn-primary" type="submit" name="submit">Review</button>
<?php } ?>
I am making a Modal Form that pops up on Click of a button and opens up a input field.
On Save it pushes the values to webpage URL that it is poping up from.
I am trying to capture that value and update on the database.
Which is happening perfectly fine.
But I want to refresh the page as the URL still holds the value for from the Modal form.
<div id="custom-modal" class="modal-demo">
<button type="button" class="close" onclick="Custombox.close()"><span>×</span><span class="sr-only">Close</span></button>
<h4 class="custom-modal-title">Add New Category</h4>
<div class="custom-modal-text text-left">
<form role="form">
<div class="form-group" method="post">
<label for="name">Category Name</label>
<input type="text" class="form-control" id="cat_name" name="cat_name" placeholder="Enter category name">
</div>
<button type="submit" class="btn btn-default waves-effect waves-light" name="btn-savecat" id="btn-savecat">Save</button>
<button type="button" class="btn btn-danger waves-effect waves-light m-l-10">Cancel</button>
<?php
if(isset($_GET['cat_name']))
{
try
{
$id=$_GET['cat_name'];
$result = $DB_con->prepare("INSERT INTO category(cat_name,cat_status)
VALUES(:userid,'Active')");
$result->bindParam(':userid', $id);
$result->execute();
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
?>
</form>
</div>
I think you should be able to do it with new HTML5. There is an option for rewriting url without reloading the page. You cannot however change the domain name for security reasons. Look up history api.
I think it would be something like the following:
history.replaceState("object or string", "title", "/another-new-url");
Check this one out.
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'.