1

OK I might be a bit out of my depth here I have a page like this:

enter image description here

Now When Someone clicks the button a fancy sliding page "slides" over the current page, asking for the user to enter his application details.

enter image description here

Now I need to get the clicked Button's value which contains the jobID primary key inorder for me to process the application data...makes sense?

What I would like to know is, since no actual page is loaded and no data gets send, (its only css & jquery providing a "modal" for the application page).

How would I go about finding the value of button. Im not sure where to start really?

  1. Is it possible getting it with PHP alone? (again keeping in mind no actual data gets send)?
  2. Can the value be retrieved with AJAX?
  3. Would it require some sort of completely different language like node.js or similar?

Any tips / advice / references appreciated

4 Answers 4

3

This ajax example help you you get your click value you have to set onclick button attribute in your html.

<script type="text/javascript">

  function loadajax(value){
      if (window.XMLHttpRequest) {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
      } else {
          // code for IE6, IE5
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      var pid = value;
      alert(pid);
      var queryString = "?send your primary key id or jobid=" + pid;
      xmlhttp.open("POST","Page name" + queryString,true);
      xmlhttp.send();
    }

</script>
Sign up to request clarification or add additional context in comments.

Comments

3
  1. Yes. PHP can return to you only a JSON data
  2. Yes, You can do AJAX
  3. No. PHP, HTML, CSS, JavaScript are enough. Maybe you can use Bootstrap css framework and JQUERY I recommend: You can use html decoration. Its mean: to define your own HTML attributes. Example:

    <a class="view" href="javascript:;" data-id="111" >VIEW</a>

Javascript code:

<script language="JavaScript">
     $("a.view").click(function(){
            var jobId = $(this).attr("data-id");
            $.ajax({
                url: "[YOUR_URL]",
                data:{"job_id":jobId},
                type:"post", 
                success:function(response){
                    //You must open your css modal window and fill
                } 
            })
     }); 
</script>

PHP code:

<?php
header('Content-Type: application/json; charset=utf-8');
$responseData = []; // you fill this variable with response data
echo json_encode($responseData);

Comments

1

For your apply button , have an onclick registered to some function in javascript along with the event passed in the given manner :

<button value="(whatever)" onclick ="sendreq(event)" >

Now in your javascript , have a function sendreq(e) :

 function sendreq(e)
 {
   var jobId = e.target.value;
   //Process your data however with this jobId you have
   //Make XMLHttpRequest() and open a post ajax call of your choosing.

 } 

The variable jobId will contain what you require .

Comments

1

1st you can not show the module where you set jobID.

If you want to get directly JobID then try '$_POST[]' method in URL itself like http://yourURL.Domain/?id='jobId' and it will directly move or use for next page as well as current page also. . .

But in that way JobID will show in URL. :(

if You want to go on AJAX then it is better. . .

otherwise try html+php I hope that is useful . . .

<!-- this is Simple code for idea what i say. . .-->
  <html>
    <body>
     <form action="#" method="post">
       <input type = "XYZ" id="JobID">
       <input type = "Submit" value="submit">
      </form>
    </body>
  </html>

   <?php 
        if(isset($_POST['JobID']))
         //USE JobID 
    ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.