a href pass same value to the modal
<p>I am using wordpress for my site and i want to add a new module to my existing wordpress site. I upload some pdf files from the backend. Many unknown viewer download it. But main thing is , need to know who download it. For this issue i added a module which has a modal when we click the file link, have some details like name, phone, email id and filename with captcha. i upload the files using cptui, custom fields and acf repeater. But a href doesnt passes the onclick value to the module form field.</p>

<p>Here file loop code:</p>

<pre><code>&lt;?php
    /**
     * Template Name: Downloads
     *
     * @package WordPress
     * @subpackage Twenty_Fourteen
     * @since Twenty Fourteen 1.0
     */

    get_header(); ?&gt;
    &lt;script  src="https://code.jquery.com/jquery-3.0.0.js" integrity="sha256-jrPLZ+8vDxt2FnE1zvZXCkCcebI/C8Dt5xyaQBjxQIo=" crossorigin="anonymous"&gt;&lt;/script&gt;
    &lt;script src='https://www.google.com/recaptcha/api.js'&gt;&lt;/script&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;
        &lt;!-- Include all compiled plugins (below), or include individual files as needed --&gt;
        &lt;script src="js/bootstrap.js"&gt;&lt;/script&gt;
        &lt;!-- InstanceEndEditable --&gt;
        &lt;script language="JavaScript" type="text/javascript"&gt;
     function isempty(elem,errmsg)
     {
      with(elem)
      {
       if((value.length==0) || (value==""))
       {
        alert(errmsg);
        return false;
       }
       else { return true;}
      }
     }

     function validmail(id,errmsg)
     {
      with(id)
      {
       at=value.indexOf("@");
       dot=value.lastIndexOf(".");

       if(at&lt;1 || (dot-at)&lt;2 )
       {
        alert(errmsg);
        return false;
       }
       else { return true;}   
      }
     }


     function formvalidation(thisform)
     {
      with(thisform)
      {
       if(isempty(name,"Enter the Name!")==false)
       {
        name.focus();
        return false;
       }

       else if(isempty(email,"Enter E-mail id!")==false)
       {
        email.focus();
        return false;
       }

       else if(validmail(email,"Invalid E-mail id!")==false)
       {
        email.focus();
        return false;
       }



       else if(isempty(phone,"Enter the Phone Number!")==false)
       {
        phone.focus();
        return false;
       }  

    else if(phone.value.length !== 10) {
        window.alert("Phone number must be 10 digits.");
        phone.focus();
        return false;
    }
        else if(isempty(address,"Enter Address!")==false)
       {
        address.focus();
        return false;
       }

      else if(isempty(enquiry,"Enquiry!")==false)
       {
        enquiry.focus();
        return false;
       }

      }
     }



     function valNumeric(evt) 
        {            

            var charCode = (evt.which) ? evt.which : event.keyCode
             if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
             {
              alert("Enter Only Numbers")
                return false;
             }

             return true;
        }

          &lt;!--Function to accept only Alphabet values--&gt;           
            function ValidateAlpha(evt)
            {
                var keyCode = (evt.which) ? evt.which : event.keyCode

                if ((keyCode &lt; 65 || keyCode &gt; 90) &amp;&amp; (keyCode &lt; 97 || keyCode &gt; 122) &amp;&amp; (keyCode !=32 &amp;&amp; keyCode !=08))
                {
                alert("Enter Only Alphabets");
                 return false;
                }
                    return true;

            }

    $('myModal').on('show.bs.modal', function (event) {
      var a = $(event.relatedTarget) // Button that triggered the modal
      var recipient = a.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(recipient)
      modal.find(filename.value).val(recipient)
    })
    &lt;/script&gt;
    &lt;script type="text/javascript"&gt;
    function updateVal(file_url)
    {
      return(file_url); 
      alert(file_url); 
    }   
    document.getElementById('fileurl').value = updateVal(file_url);
    &lt;/script&gt;

    &lt;?php session_start();

    if(isset($_POST['Submit'])){
        // code for check server side validation
        if(empty($_SESSION['captcha_code'] ) || strcasecmp($_SESSION['captcha_code'], $_POST['captcha_code']) != 0){  
            $msg="&lt;span style='color:red'&gt;The Validation code does not match!&lt;/span&gt;";// Captcha verification is incorrect.     
        }else{// Captcha verification is Correct. Final Code Execute here!      
            $msg="&lt;span style='color:green'&gt;The Validation code has been matched.&lt;/span&gt;";      
        }
    }   
    ?&gt;
    &lt;script type='text/javascript'&gt;
    function validateCaptcha()
    {
        if ($('input[name="valid"]')) return true;
        if ($('input[name="recaptcha_response_field"]').val() == "")
        {
            alert("Please complete the CAPTCHA field.");
            return false
        }
    }
    &lt;/script&gt;

                &lt;div class="container" id="post-page-cust"&gt;
    &lt;?php

        // WP_Query arguments

        $args = array (

            'post_type'              =&gt; 'downloads',

            'category_name'          =&gt; 'annual-report',
            'order'                  =&gt; 'ASC',

        'orderby'                =&gt; 'title',


        );

         // The Query

        $query = new WP_Query( $args );



        // The Loop


        if ( $query-&gt;have_posts()) {

            while ( $query-&gt;have_posts() ) {
            $query-&gt;the_post();
                ?&gt;
    &lt;h1&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to &lt;?php the_title(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt; 
    &lt;?php
    if( have_rows('pdf_file') ):?&gt;
    &lt;?php // loop through the rows of data
        while ( have_rows('pdf_file') ) : the_row();
    $file_name = get_sub_field('file_name'); 
     $file_original =  get_sub_field('upload_your_pdf');
     $file_url=$file_original['url'];
            echo'&lt;a title="'.$file_name.'" onclick="updateVal('.$file_url.')" data-toggle="modal" data-target="#myModal" ondata-whatever="'.$file_name.'" href="#myModal"&gt;'.$file_name.'&lt;/a&gt;&lt;br&gt;';

    echo'
      &lt;!-- Modal --&gt;
      &lt;div class="modal fade" id="myModal" role="dialog"&gt;
        &lt;div class="modal-dialog"&gt;

          &lt;!-- Modal content--&gt;
          &lt;div class="modal-content"&gt;
            &lt;div class="modal-header"&gt;
              &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
              &lt;h4 class="modal-title"&gt;Entry Form&lt;/h4&gt;
            &lt;/div&gt;
            &lt;div class="modal-body"&gt;
                    &lt;!-- The form is placed inside the body of modal --&gt;
                     &lt;form class="form-horizontal" onSubmit="return formvalidation(this);" action="http://192.146.1.256/download/?page_id=10" method="POST"&gt;
    &lt;fieldset&gt;

    &lt;!-- Form Name --&gt;
    &lt;!-- Text input--&gt;
    &lt;div class="form-group"&gt;
      &lt;label class="col-md-4 control-label" for="name"&gt;Name&lt;/label&gt;  
      &lt;div class="col-md-6"&gt;
      &lt;input id="uname" type="text" name="uname" placeholder="" onkeypress="return ValidateAlpha(event)" class="form-control input-md" required=""&gt;

      &lt;/div&gt;
    &lt;/div&gt;

    &lt;!-- Text input--&gt;
    &lt;div class="form-group"&gt;
      &lt;label class="col-md-4 control-label" for="phone"&gt;Phone&lt;/label&gt;  
      &lt;div class="col-md-6"&gt;
      &lt;input id="phone" type="text" name="phone" placeholder="" class="form-control input-md" onkeypress="return valNumeric(event)" required=""&gt;

      &lt;/div&gt;
    &lt;/div&gt;

    &lt;!-- Text input--&gt;
    &lt;div class="form-group"&gt;
      &lt;input type="hidden" name="fileurl" id="fileurl" /&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;label class="col-md-4 control-label" for="email"&gt;Email&lt;/label&gt;  
      &lt;div class="col-md-6"&gt;
      &lt;input id="email" type="email" name="email" placeholder="" class="form-control input-md" required=""&gt;

      &lt;/div&gt;
    &lt;/div&gt;


    &lt;!-- Button --&gt;
    &lt;div class="form-group"&gt;&lt;center&gt;
      &lt;div class="col-md-4"&gt;
        &lt;button id="submit" onclick="return validate();" name="submit" value="Submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;/fieldset&gt;
    &lt;/form&gt;&lt;/center&gt;


                    &lt;/div&gt;
            &lt;div class="modal-footer"&gt;
              &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
            &lt;/div&gt;
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;';
      endwhile;
    else :
        // no rows found
    endif; 
    echo '
    &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;a style="font-weight:bold" href="http://192.146.1.256/download-sacon/wp-admin/tools.php?page=databasebrowser"&gt;Download Tracker&lt;/a&gt;
    &lt;/div&gt;
    &lt;/div&gt;
    &lt;/div&gt;';
    ?&gt;
    &lt;?php 

                // You can all phone/ email here
            }
        } 


    ?&gt;
                &lt;/div&gt;
    &lt;script&gt;
    $('.modal').on('hidden.bs.modal', function(){
        $(this).find('.form-horizontal')[0].reset();
    });&lt;/script&gt;
    &lt;?php ?&gt;
    &lt;?php get_footer(); ?&gt;
</code></pre>