Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery table edit - can't set vars
    primarykey
    data
    text
    <p>UPDATED: Figured it out... needed to go up a level in the DOM first.</p> <pre><code> var map_id = $(this).parent().find(".map_id").attr('value'); var corrected_isin= $(this).parent().find(".corrected_isin").val(); var corrected_cusip = $(this).parent().find(".corrected_cusip").val(); var corrected_ticker = $(this).parent().find(".corrected_ticker").val(); </code></pre> <p>I am having a lot of trouble getting jquery to work for me... I am trying to update a table of data. All my updating code works fine, but for whatever reason, the variables I am trying to set with jquery are continuously undefined. The code below is not setting the variables. When i hardcode the variables, it works ok. I have also tried using IDs instead of classes to no avail. Please help!</p> <p>Thank you,david</p> <pre><code> var map_id = $(this).children(".map_id").attr('value'); var corrected_isin = $(this).children(".corrected_isin").val(); var corrected_cusip = $(this).children(".corrected_cusip").val(); var corrected_ticker = $(this).children(".corrected_ticker").val(); </code></pre> <p>Full Code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;ISIN Editor&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function(){ $("form").submit(function() { var map_id = $(this).children(".map_id").attr('value'); var corrected_isin = $(this).children(".corrected_isin").val(); var corrected_cusip = $(this).children(".corrected_cusip").val(); var corrected_ticker = $(this).children(".corrected_ticker").val(); $.ajax({ type: "GET", url: "aj/table_edit_ajax.php", data: {corrected_isin: corrected_isin, corrected_cusip: corrected_cusip, corrected_ticker: corrected_ticker, map_id: map_id}, cache: false, success: function(){ alert(map_id + " " + corrected_isin + " " + corrected_cusip + " " + corrected_ticker ); } }); return false; }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;?php include("aj/db.php"); $query = "SELECT map_id, ria_crd, position_cusip, position_ticker, position_description, position_first_date, position_last_date, map_corrected_isin, map_corrected_cusip, map_corrected_ticker FROM map_to_isin WHERE map_correct_status IN (2,5)"; $result = mysql_query($query,$bd); ?&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;map_id&lt;/th&gt; &lt;th&gt;RIA CRD&lt;/th&gt; &lt;th&gt;Reported CUSIP&lt;/th&gt; &lt;th&gt;Reported Ticker&lt;/th&gt; &lt;th&gt;Reported Description&lt;/th&gt; &lt;th&gt;Date Range&lt;/th&gt; &lt;th&gt;New isin&lt;/th&gt; &lt;th&gt;New CUSIP&lt;/th&gt; &lt;th&gt;New Ticker&lt;/th&gt; &lt;th&gt;Submit Change&lt;/th&gt; &lt;/tr&gt; &lt;?php $row_num = 1; while($row = mysql_fetch_array($result)) { echo "&lt;tr"; if($row_num%2) { echo " bgcolor='pink'"; }; echo "&gt;"; ?&gt; &lt;form id="form&lt;? echo $row['map_id'] ?&gt;"&gt; &lt;input type="hidden" name="map_id" class="map_id" value="&lt;? echo $row['map_id'] ?&gt;"/&gt; &lt;td&gt;&lt;? echo $row['map_id'] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;? echo $row['ria_crd'] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;? echo $row['position_cusip'] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;? echo $row['position_ticker'] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;? echo $row['position_description'] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;? echo $row['position_first_date'] . " -&gt; " . $row['position_last_date'] ?&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="corrected_isin" class="corrected_isin" value="&lt;? echo $row['map_corrected_isin'] ?&gt;"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="corrected_cusip" class="corrected_cusip" value="&lt;? echo $row['map_corrected_cusip'] ?&gt;"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="corrected_ticker" class="corrected_ticker" value="&lt;? echo $row['map_corrected_ticker'] ?&gt;"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='submit' value='Update' /&gt;&lt;/td&gt; &lt;/form&gt; &lt;/tr&gt; &lt;?php $row_num ++; } echo "&lt;/table&gt;"; mysql_close($bd); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload