0

I'm using Wordpress to create my theme on selling boats. So far I got this plugin Search and Filter to work on selecting what kind of boat the custom wants.

Now after the custom has the options for the boat they want I want to have an checkbox (or something else) to save this boat or boats if more are available.

So I can sent a contact message (contact form 7) that displays the boats that the customer has selected, so I know what information he or she wants.

Using this code:

<label><input type='checkbox' onclick='handleClick(this);'>Checkbox</label>

function handleClick(cb) {
  display("Clicked, new value = " + cb.checked);
}

Example | Source (credits go to: T.J. Crowder)

I can output a true or false value but not (at the moment) the name of the boat.

Is there a good way to make this work?

In my header I have started a session

 <?php
session_start();
?>

So I could be able to echo values from anywhere right? I know the script and the session are separate things. But what would be the best way to solve my question?

UPDATE: Ok i found this bootstrap modulo code that lets me do 'stuff' with ajax and probably write in my session. Can someone tell me how I do this?

<script>
    $('.post-<?php the_ID(); ?>').on('show.bs.modal', function (event) {
        var button = $(event.relatedTarget) // Button that triggered the modal
        var recipient = button.data('whatever') // Extract info from data-* attributes
        // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
        // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
        var modal = $(this)
        modal.find('.modal-title').text('New message to ' + recipient)
        modal.find('.modal-body input').val(recipient)
    })
</script>

<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".post-<?php the_ID(); ?>" data-whatever="@mdo">Open modal for @mdo</button>
    <div class="modal fade post-<?php the_ID(); ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="exampleModalLabel"><?php the_title(); ?></h4>
          </div>
         <div class="modal-body">
            <p>Boot <?php the_title(); ?></p>
                <hr>
                <p><?php the_title(); ?></p> 
         </div> 
         <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Sluiten</button>
        </div>
     </div>
    </div>
   </div>
Community
  • 1
  • 1
Steggie
  • 525
  • 8
  • 31

0 Answers0