questions

How can I add a parameter to the URL

Rate this post

The form sends a user to a URL using the parameters when submitted. I want to add a parameter to the final url link. I am using ACF (advanced custom fields) to display the parameter.

How I add <?php echo esc_url( $linkname ); ?> so it appends the final url link for when the button is submitted:

<form class="booking-form clearfix" action="https://app-apac.thebookingbutton.com/properties/yaangcomedirect" name="check">
Start Date : <input type="text" name="check_in_date" id="check_in_date" value="" /> 
End Date : <input type="text" name="check_out_date" id="check_out_date" value="" /> 
 <select id="prefill-8-19" class="form-control gdlr-combobox-wrapper" name="number_adults">
         <option selected="selected" value="1 Adult">1 Adult</option>
         <option value="2 Adults">2 Adult</option>
         <option value="3 Adults">3 Adult</option>
         <option value="4 Adults">4 Adult</option>
         <option value="5 Adults">5 Adult</option>
         <option value="6 Adults">6 Adult</option>
         <option value="7 Adults">7 Adult</option>
         <option value="8 Adults">8 Adult</option>
         <option value="9 Adults">9 Adult</option>
         <option value="10 Adults">10 Adult</option>
     </select>
     <select id="prefill-8-19" class="form-control gdlr-combobox-wrapper" name="number_children">
        <option selected="selected" value="0 Children">0 Children</option>
        <option value="1 Children">1 Children</option>
        <option value="2 Children">2 Children</option>
        <option value="3 Children">3 Children</option>
        <option value="4 Children">4 Children</option>
        <option value="5 Children">5 Children</option>
        <option value="6 Children">6 Children</option>
        <option value="7 Children">7 Children</option>
        <option value="8 Children">8 Children</option>
        <option value="9 Children">9 Children</option>
        <option value="10 Children">10 Children</option>
        <option value="11 Children">11 Children</option>
        <option value="12 Children">12 Children</option>
    </select>
<input name="check" type="submit" class="btn btn-default" value="Check Availability">
</form>

 

✔️Solution:

You can pass using a hidden input field like this:

<input type="hidden" name="linkname" value="<?php echo esc_url( $linkname ); ?>">

So final code would be like this:

<form class="booking-form clearfix" action="https://app-apac.thebookingbutton.com/properties/yaangcomedirect" name="check">
Start Date : <input type="text" name="check_in_date" id="check_in_date" value="" /> 
End Date : <input type="text" name="check_out_date" id="check_out_date" value="" /> 
 <select id="prefill-8-19" class="form-control gdlr-combobox-wrapper" name="number_adults">
         <option selected="selected" value="1 Adult">1 Adult</option>
         <option value="2 Adults">2 Adult</option>
         <option value="3 Adults">3 Adult</option>
         <option value="4 Adults">4 Adult</option>
         <option value="5 Adults">5 Adult</option>
         <option value="6 Adults">6 Adult</option>
         <option value="7 Adults">7 Adult</option>
         <option value="8 Adults">8 Adult</option>
         <option value="9 Adults">9 Adult</option>
         <option value="10 Adults">10 Adult</option>
     </select>
     <select id="prefill-8-19" class="form-control gdlr-combobox-wrapper" name="number_children">
        <option selected="selected" value="0 Children">0 Children</option>
        <option value="1 Children">1 Children</option>
        <option value="2 Children">2 Children</option>
        <option value="3 Children">3 Children</option>
        <option value="4 Children">4 Children</option>
        <option value="5 Children">5 Children</option>
        <option value="6 Children">6 Children</option>
        <option value="7 Children">7 Children</option>
        <option value="8 Children">8 Children</option>
        <option value="9 Children">9 Children</option>
        <option value="10 Children">10 Children</option>
        <option value="11 Children">11 Children</option>
        <option value="12 Children">12 Children</option>
    </select>
<input name="check" type="submit" class="btn btn-default" value="Check Availability">
<input type="hidden" name="linkname" value="<?php echo esc_url( $linkname ); ?>">
</form>

Leave a Reply

Your email address will not be published.

Back to top button