Buttons experiencing issues with modal class functionality

I have a form that needs to be filled out.

<form action="../massmail.php" method="post">
        <label>Period:</label>
        <div class="form-inline"><input class="form-inline input-small" name="month" type="text" placeholder="e.g.: June" /> 
            <input class="input-mini" name="year" type="text" value="2015" />
        </div>
        <br />
        <label>Introductory text:</label>
        <div>
            <textarea name="introduction" rows="5"></textarea>
        </div>
        <br />
        <label>URL of the newsletter:</label>
        <div>
            <input class="input-xxlarge" name="newsletter_link" type="url" value="" />
        </div>
        <div class="form-actions">
            <button class="btn btn-primary" type="submit">Send</button>
            <button class="btn" formaction="../preview.php" formmethod="get" type="submit">Preview</button>
            <a href="index.php"><button class="btn" type="button">Cancel</button></a>
        </div>
    </form>

The form controls are contained within the last <div>. The second button is intended to show a preview before submitting the form, overriding the default form action.

Although it currently works, I want the preview to appear in a modal window (pop-up). Unfortunately, the modal class only works with <a> elements. In the past, I have resolved this by setting the class of the <a> element to "btn modal", but in this case, I require an actual button due to the need for the 'formaction' attribute.

Here are the things I have attempted along with their outcomes:

<button class="btn modal" formaction="../preview.php" formmethod="get" type="submit" rel="{handler: 'iframe', size: {x: 920, y: 530}}">Preview</button>

Outcome: The form behaves as expected, but no pop-up window appears; instead, the results are displayed as if a link has been opened to the PHP page.

<a class="modal" href="preview.php" rel="{handler: 'iframe', size: {x: 920, y: 530}}"> <button class="btn" type="button" formaction="../preview.php" formmethod="get" type="submit">Preview MOD</button> </a>

Outcome: This opens the pop-up with the PHP page but does not pass the results from the form to the PHP page.

The snippet includes modal.css, which does not appear to have any specific styling for <a> or <button> elements. Additionally, there is javascript included in modal.js, although my familiarity with it is limited.

I am attempting these modifications within a custom HTML module in Joomla! 3.4.3.

Any assistance would be greatly appreciated.

Answer №1

Issue resolved successfully. I have implemented the second line (functioning popup).

<a class="btn modal" href="voorbeeld.php" rel="{handler: 'iframe', size: {x: 920, y: 530}}">Voorbeeld</a>

Although the popup opens as intended, it does not seem to handle the form submission. Therefore, I removed the button inside the <a> tag which was supposed to submit the form but failed to do so in the popup.

I then fetched the form data using JavaScript with the following code:

var id = window.parent.document.getElementById('id').value;

To make this technique work, all form elements needed in the popup must be assigned an id.

I hope this information benefits anyone facing a similar issue.

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

Make a quick call to the next function within the error handling module for a

Currently, I am facing an issue while trying to call the next function within the error handler of my node + express js application. In each controller, I have a middleware known as render which is invoked by calling next, and I wish to achieve the same f ...

Google has not detected any hreflang return tag

My website has encountered indexing errors on Google Search Console. According to the reports, many pages are showing an alternate version in a different language without the "return tag". This "return tag" is believed to be the pointer back to the origina ...

Promise rejection caused by SyntaxError: Unexpected token i found in JSON at position 0 while trying to fetch a raw file from Gitlab

I'm attempting to retrieve a raw file from a Gitlab repository by following the official documentation. Here are the functions in question: methods: { async getProjects(url, method, payload) { const token = this.$store.getters.token ...

problems arise due to padding and floating on the navigation bar

I have been facing a couple of challenges with my code. Firstly, I am trying to remove the small annoying line underneath my selected navigation links and also attempting to float both the header and footer to the right without losing their backgrounds. I ...

Different ways to refresh a list rendered using .map()

I'm having trouble updating a list when I click a button that moves the first element of the array to the last position. Even though the console.log confirms that the array has been modified, the component does not rerender: codesandbox import React, ...

How can jQuery data() be used with multiple arguments?

Is it possible to add multiple data variables to an element before triggering a specific action? If so, how can I achieve this? $("#dlg_box").data("r_redirect","index.php").dialog("open"); ...

An AngularJS project utilizing exclusively EJB

Can an AngularJS application be built directly with EJB without needing to expose them as REST services? Many examples on the internet show that eventually REST services are required to provide data to AngularJS. This means that EJB methods must be expos ...

The Forge Viewer's getState() function is providing inaccurate values for individual items

In our Angular application, we have integrated the latest version of Forge Viewer and are storing the current state of the viewer in our database for future restoration. After thorough testing, we discovered that isolated nodes are not being saved correct ...

How to retrieve a specific value using jQuery based on the name attribute

I'm having an issue retrieving the selected value from the menu and assigning it to the `country` variable. Whenever I try, I keep encountering the error: No parameterless constructor defined. The `UpdateClient` function is triggered by clicking on t ...

What is the best way to retrieve a random amount of lines of data from the stdin in Node.js?

Currently, I am attempting to execute a basic program in the Visual Studio Code terminal using node.js. This program involves reading inputs from the user, performing operations on those inputs, and displaying the results. Despite trying various methods, ...

IE not sending variable to the server

I have a webpage where I am using checkboxes and I want to retrieve the values of the checked ones using PHP. Below is the code snippet: <input id=checkBoxChrome form="saveform" type="checkbox" name="checkbox[]" value="Chrome" checked > And here i ...

Instructions on how to apply dual light maps to separate objects with identical materials

Is there a way to add a light map to two objects that share the same material and have some animation without modifying the shared material directly? I attempted the following approach: childer[i].materials.lightMap=ObjectsLightMaps[childer[i].id]; Howev ...

"Sending a POST request from the smartphone application client developed using the Meteor

I'm currently working on a simple mobile app with Meteor that aims to send user location data to a geospatial database or server. However, I'm facing some challenges and uncertainties about the feasibility of this task using Meteor. The issue ari ...

Looking for a simple method to apply experimental and consistent CSS across various browsers?

Is there a tool available that can automatically enhance CSS by adding experimental properties to ensure consistent appearance across different browsers? For instance, rather than manually including: .class { -moz-border-radius: 8px; -webkit-borde ...

Why can't we import Angular 4 as a library similar to AngularJS?

Why was AngularJS introduced as a script to import in an HTML page? However, in the newer version Angular 4, we need to use a web server to launch the application? Is it because AngularJS is not considered a framework but Angular 4 is? Thank you. ...

Adding the expanded search icon to a text box in Vuetify: A step-by-step guide

Recently, I integrated Vuetifyjs into my right-to-left (RTL) Vue 2 project. Within a card element, I inserted a table and included a search bar following the documentation. Now, I have two specific goals in mind: Relocate the "number of items to show" opt ...

Error: The number of parameters provided does not match the expected count

Encountering an issue in both firefox and google chrome : Sys.ParameterCountException: Parameter count mismatch. The javascript method being called via onclick is as follows: <script type="text/javascript"> var confirmSubmited = false; ...

Having trouble setting up the rootReducer using combineReducers

import { combineReducers } from 'redux'; import { reducers } from './reducers'; import { IAppAction } from './action'; import { routerReducer } from 'react-router-redux'; import { IAppState } from './state/app-s ...

Creating UL tabs using just HTML and CSSHere's a step-by-step guide

Looking for help to accomplish this task. I already have the styling, but I want something to happen when I click on the tabs. Specifically, I want the div with the tab class names to show and hide upon clicking the tabs. Currently, nothing happens when I ...

Exploring the world of third-party widgets: Comparing Angular, jQuery, and traditional JavaScript

I have a plan to develop a simple embeddable widget similar to Google ads or Facebook like box. Users will be able to easily add the widget to their website and I will extract some parameters to fetch data from my servers. Previously, I relied on jQuery f ...