Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing 2 php variables using javascript/JQuery
    primarykey
    data
    text
    <p>I have a Jquery code that listens for the selection from a user and displays the information that the user needs. The user selects a "folder" and then the content appears after they selected.</p> <p>There are 2 pages. The first page has the jquery code and the selection box and the div that the information is the be displayed in. Our problem is I got the folder name to pass but I need to pass along the $username as well so that it knows what folders to look up.</p> <p>This is the first page. It's the selection box and also jquery code.</p> <pre><code>&lt;script type="text/javascript" src="jquery-1.9.1.min.js"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $("#theselect").change(function() { var option = $(this).val(); $.get("selectfolders.php", {select:option},function(data){ $("#theresult").html(data).hide().fadeIn(1000); }); }); }); &lt;/script&gt; echo " &lt;select name='thename' id='thename' style='visibility:hidden;' &gt; &lt;option value='$username'&gt;$username&lt;/option&gt; &lt;/select&gt;"; ?&gt; &lt;select name="theselect" id="theselect"&gt; &lt;option value=""&gt;Select&lt;/option&gt; &lt;? $thelistquery = mysql_query("SELECT * FROM folders WHERE username='$username'"); while ($lrows = mysql_fetch_array($thelistquery)) { $id = $lrows['ID']; $username = $lrows['username']; $foldername = $lrows['foldername']; $newfoldername = mysql_real_escape_string($foldername); echo "&lt;option value='$newfoldername'&gt;$newfoldername&lt;/option&gt;"; } ?&gt; &lt;/select&gt; </code></pre> <p>This is the second page. It generates the list of folders and displays the folder the user selects on the first page:</p> <pre><code>$thelistquery = mysql_query("SELECT * FROM folders WHERE username='$username'"); while ($lrows = mysql_fetch_array($thelistquery)) { $id = $lrows['ID']; $username = $lrows['username']; $foldername = $lrows['foldername']; $newfoldername = mysql_real_escape_string($foldername); if($_GET['select'] == '$newfoldername') { echo "This is the $newfoldername folder."; } } </code></pre> <p>We need to add code the the javascript to take the $username from the first page and pass it to the second page so it knows whose folders to look up. Any help?</p>
    singulars
    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