Attaching Form Action to Native Wix Button

Hello. Thank you in advance for looking into my inquiry.

I’m looking to attach the following form action code to a button I created. The following code came from an external site that returns a page with no set landing URL. I only have this code:

Instant Quote

Thank you.

Nick

Hi Nick,

You can use an HTML component (Add → More → HTML iframe).

You also need to add target=“_parent” attribute to the form so that submitting the form will switch your page to the result page.

<form target="_parent" action="https://secure.dragonflycabinrentals.com/reservation_availability.asp" id="form_reserve" method="post">
<input type="Hidden" name="PageDataID" value="143773">
<input type="Hidden" name="InventoryUnitDataID" value="0">
<input type="Hidden" name="WebReferenceID" value="907">
<input type="Hidden" name="DynSiteID" value="907">
<input type="Hidden" name="WebReferencePageDataID" value="143773">
<input type="hidden" name="NavisCode" value="">
<input type="hidden" name="LeadID" id="hiddenLeadID" value="">
<button type="submit" class="form-BookItNow" alt="Reserve Mountain Song  Now" id="p-overview-bttn">Instant Quote</button>
</form>

WOW thank you! It worked!

May I ask you an additional question? Is it possible to build a hyperlink of that code and place on a button or text?

Using the HTML iFrame gives me a button but it doesn’t conform to the sites design and I’m not sure if that is possible.

Nick:

You can probably hook up a page button to the iFrame using messages.

So in your $w(‘#button’).onClick() function send a submit message to the iFrame.

$w('#iframe').postMessage('submitPressed');

Then in your iFrame code add a message handler

<script>
window.addEventListener("message", event => {
        let message = event.data;
        if (message === 'submitPressed') {
            // Execute form submit processing
        }
} );
</script>

Thank you, very informative.
Just one question, What do I write in the line of:

// Execute form submit processing

writing

document.getElementById("form_reserve").submit();

did not work.

Thanks.