grab php output using javascript in table

lordterrin

I have an HTML table that is generated from php. I utilize javascript to do something when someone selects a particular answer in a dropdown. The part of the table I care about is here:

<td style="display:none;">
<?= $lineID ?>
<value="<?= $lineID ?>"></td>

<td>
<?= $resolution ?><br>
<value="<?= $resolution ?>">                    
<select name="resolution[]" class="inputbox" onchange="submitResolution(this.value)">               
<option value="null">
</option>               
<option value="nightmareAlias.php">ADD NEW ALIAS</option>
<option value="NO PROBLEM">NO PROBLEM</option>
</td>

and here's the script that is actioned when someone selects "ADD NEW ALIAS"

<script>
function submitResolution(str) {
  console.log(str);  
  if (str =="nightmareAlias.php") {

      document.getElementById("txtHint").innerHTML="";
      $("#txtHint").load(str);
      return;     
  }
}
</script>

Right now - this works just fine. When someone selects ADD NEW ALIAS, they are redirected to the nightmareAlias.php page. When that page loads, I need to find a way to not just submit(this.value), but to almost submit the lineID of the line on the table that the person is actioning.

How do I pass this value along as well?

Matt
<select name="resolution[]" class="inputbox" data-lineid="<?= $lineID ?>" onchange="submitResolution(this)">                              
    <option value=""></option>
    <option value="nightmareAlias.php">ADD NEW ALIAS</option>
    <option value="NO PROBLEM">NO PROBLEM</option>
</select>

You need to make the line ID available, I've included it as an attribute in the select tag. Then pass this as a parameter rather than this.value so that you can access the object in its entirety.

<script>
    function submitResolution(sel) {
        console.log(sel);  
        if (sel.value === "nightmareAlias.php") {
            document.getElementById("txtHint").innerHTML="";
            $("#txtHint").load(sel.value + '?lineID=' + $(sel).data('lineid'));
            return;     
        }
    }
</script>

Then add a query parameter to the URL. You will need to handle a GET request for lineID within nightmareAlias.php.

Note the use of === rather than ==, it would also be worth separating your JavaScript and HTML more. For what you're trying to do here I would have probably used .change()

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Grab a Html section name using Javascript

분류에서Dev

Php output breaks the Javascript

분류에서Dev

Using Tweepy to grab grab coordinates and plot them

분류에서Dev

Using a function to output HTML in PHP

분류에서Dev

How to grab all regex matches in php?

분류에서Dev

How to grab username from the PHP Login Project

분류에서Dev

Javascript grab div and place it in between different divs

분류에서Dev

Javascript alerts and using php variables in javascript

분류에서Dev

delete a specific row of a table using php

분류에서Dev

Creating four columns using php loop in table

분류에서Dev

Using jQuery to grab data from JSON

분류에서Dev

how to freeze table header using javascript

분류에서Dev

How to insert markup into a table using javascript

분류에서Dev

Not getting query output wen using if condition in php mysql

분류에서Dev

How to show servlet Output it on Drop down list Using JavaScript

분류에서Dev

searching and retrieving table values using a parameter in android using php,mysql

분류에서Dev

What's the best way to grab attributes of a particular td in html table?

분류에서Dev

Grab all documents whose IDs are not present in a separate table

분류에서Dev

How to grab data from table with divs and inputs inside cells?

분류에서Dev

Changing color type of video using Javascript or PHP

분류에서Dev

dynamic calculation of input fields using php javascript

분류에서Dev

Bash: Pipe output into a table

분류에서Dev

순수 JavaScript 이미지 Grab-Zoom?

분류에서Dev

fetch id from one table and store it into another using php

분류에서Dev

How make a table with php using the echo command with looping data?

분류에서Dev

Store user edited values in a log-table using PHP or JS

분류에서Dev

How to insert record into two mysql table using php?

분류에서Dev

How to make table row at server side visible using javascript?

분류에서Dev

JSON to PHP Output

Related 관련 기사

  1. 1

    Grab a Html section name using Javascript

  2. 2

    Php output breaks the Javascript

  3. 3

    Using Tweepy to grab grab coordinates and plot them

  4. 4

    Using a function to output HTML in PHP

  5. 5

    How to grab all regex matches in php?

  6. 6

    How to grab username from the PHP Login Project

  7. 7

    Javascript grab div and place it in between different divs

  8. 8

    Javascript alerts and using php variables in javascript

  9. 9

    delete a specific row of a table using php

  10. 10

    Creating four columns using php loop in table

  11. 11

    Using jQuery to grab data from JSON

  12. 12

    how to freeze table header using javascript

  13. 13

    How to insert markup into a table using javascript

  14. 14

    Not getting query output wen using if condition in php mysql

  15. 15

    How to show servlet Output it on Drop down list Using JavaScript

  16. 16

    searching and retrieving table values using a parameter in android using php,mysql

  17. 17

    What's the best way to grab attributes of a particular td in html table?

  18. 18

    Grab all documents whose IDs are not present in a separate table

  19. 19

    How to grab data from table with divs and inputs inside cells?

  20. 20

    Changing color type of video using Javascript or PHP

  21. 21

    dynamic calculation of input fields using php javascript

  22. 22

    Bash: Pipe output into a table

  23. 23

    순수 JavaScript 이미지 Grab-Zoom?

  24. 24

    fetch id from one table and store it into another using php

  25. 25

    How make a table with php using the echo command with looping data?

  26. 26

    Store user edited values in a log-table using PHP or JS

  27. 27

    How to insert record into two mysql table using php?

  28. 28

    How to make table row at server side visible using javascript?

  29. 29

    JSON to PHP Output

뜨겁다태그

보관