Guide on transferring the value within a toggle button using bootstrap

Can someone help me figure out how to use the POST method to pass values from this toggle button code?

<div class="form-group col-md-4">
 <label>Sold Out</label>
 <div> 
   <button data-toggle="collapse">YES</button>
   <button data-toggle="collapse">NO</button>
 </div>
</div>

Answer №1

Give this a shot!

<?php
    if (isset($_POST['yesBtn'])) {
        echo "<p>".$_POST['yesBtn']."</p>";
    }
    if (isset($_POST['noBtn'])) {
        echo "<p>".$_POST['noBtn']."</p>";
    }
?>
<form action="somefile.php" method="POST">
    <div class="form-group col-md-4">
        <label>Available Options</label>
        <div> 
            <button data-toggle="collapse" name="yesBtn" value="YES">YES </button>
            <button data-toggle="collapse" name="noBtn" value="NO">NO</button>
        </div>
    </div>
</form>

Alternatively, you can try this:

<?php
    if (isset($_POST['Btn'])) {
        echo "<p>".$_POST['Btn']."</p>";
    }
?>
<form action="somefile.php" method="POST">
    <div class="form-group col-md-4">
        <label>Sold Out</label>
        <div> 
            <button data-toggle="collapse" name="btn" value="YES">YES </button>
            <button data-toggle="collapse" name="btn" value="NO">NO</button>
        </div>
    </div>
</form>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you include text within the border of a table?

Currently tackling my homework assignment which involves creating a virtual chessboard. Progress has been smooth thus far, as I've managed to write the code for it: I am now looking to incorporate Letters (A-H) and Numbers (1-8) around the board, rep ...

Struggling to make $.ajax.mostRecentCall function properly in jasmine 2.0.2

Struggling to make a basic example work properly. I found this code snippet on https://gist.github.com/Madhuka/7854709 describe("Check for spies", function() { function callFunction(callbacks, configuration) { $.ajax({ url: configurat ...

iOS devices will not scroll horizontally if there is a div that scrolls vertically within a div that scrolls horizontally

Picture a div that scrolls horizontally, housing two vertical-scrolling divs. You'll need to scroll left and right to navigate, then up and down inside the inner divs to read the content. /* RESET TO MINIMUM */ body, html { height: 100%; mar ...

Guide to adjusting the screen resolution on your iPad 3

Hello everyone, I'm fairly new to designing for the iPad 3. Could someone please provide some guidance on how to set media queries specifically for the iPad 3? Thank you in advance. ...

Reordering Divs in Bootstrap 3 Specifically for Small Screens

Just getting started with my first responsive design project, and I'm wondering if it's possible to achieve something like this using Bootstrap 3. The goal is to switch from the current layout: https://i.stack.imgur.com/lABXp.jpg To https://i. ...

Javascript textbox and submit button

Is there a way to generate a text box with a submit button and save the input into a JavaScript variable? ...

tips on adjusting the page results and maximum results for a dataTable

I have retrieved over 100 rows from MySQL, which is the default limit for displaying results in DataTables. I want to change the default limit of Datatables to display 30 rows on each page until all my fetched MySQL results are shown. When querying M ...

Guide to changing the color of HTML cells depending on the dynamic text

I'm in the process of developing a game dashboard that not only updates cell statuses but also changes their color accordingly. The backend is powered by a Python script utilizing Flask to serve the page. Main HTML Dashboard <!DOCTYPE html> < ...

Ways to align images of the same size in a gallery using the margin: auto property

I have an image gallery within a div element named "container" with a specified width:70%. I need the images to be justified with auto margins. This is the HTML code I am using: (There are 4 images in total) <div class="container"> < ...

Step-by-step guide on displaying a fresh page within a JavaScript code

I've been working with XHTML, JSF, and JavaScript to develop a form that validates user input in selected fields when a button is clicked. The goal is to redirect the user to a different page called homepage.xhtml after successful validation. However, ...

What is the process for embedding images and text within a nested division element?

I have a website layout with 4 main sections: header, left side, right side, and footer. I would like to further divide the header into two sections - left header and right header. The right header should contain an image along with other options like home ...

Leveraging flask/jinja for incorporating dynamic content without the need for an HTML table

Although I'm not well-versed in web development, I hope this question is on the right track. In my flask app, I'm trying to create a section that showcases albums/cards in a similar style as seen on this example. My goal is to display multiple ...

Incorporate a background image and overlay it with CSS animations for a dynamic effect

I have set up a fiddle, but it seems like the display is not quite right. You can check it out here - http://jsfiddle.net/kVNQb/ - although it might be helpful to take a look at the code regardless. The snow animation I am using is from this website: My ...

Determining the size of an object in ASP.net as a percentage of the page, while taking into account the size of

I need help adjusting the size of a silverlight app on a page with multiple banners above it. My goal is to make the app's height always 100% of the screen height minus the banner's height to prevent any scroll bars from appearing. Does anyone kn ...

Why isn't my CSS code responding to the media query properly?

Currently, I am utilizing media queries to adjust the appearance of my website based on different screen sizes... Below is an excerpt of my HTML code: <meta name="viewport" content="width=device-width, initial-scale=1"> <l ...

The ASP.Net email contains a hyperlink designed to open in a new window

I am currently facing an issue with an email I need to send. The problem lies in the hyperlink that is intended to open a specific page in a new tab or window upon clicking. The main issue at hand is that there is no space between the querystring variable ...

Leverage AJAX data to dynamically generate an input field within a Laravel application

. Hey everyone, I'm currently working on implementing ajax for a search functionality. The goal is to display links to the search results' pages along with checkboxes next to each result, allowing users to select orders for printing. Although I ...

Create your own unique Bootstrap 4 build with our custom generator and download it

Is there a tool similar to the alpha/beta bootstrap 3 custom generator for bootstrap 4? I'm looking for something like the one available at Customize and download. https://getbootstrap.com/docs/4.0/customize/ is not currently accessible. ...

Centering the scroll bar with Flexbox

Is it possible to center the scroll bar of a flex box in the middle of the screen? Currently, when using the code below I am seeing the UI as shown below, with the scroll bar at the bottom of the container DIV https://i.sstatic.net/XakpC.png Instead, is ...

ajax does not reload the form after submission but successfully sends the data

Here is the code I created for a voting system. This is a test outside of my main website. I am new to ajax and jquery and I am struggling with understanding why I don't get the form resubmission after submitting the form. The data is still posted, an ...