Note that there are some explanatory texts on larger screens.

plurals
  1. POFrom php I create a HTML form that mult selects items in a table - I want to send the selected items with some bits of information using javascript
    text
    copied!<p>Need help sending data from a table in html in a php file sending to a javascript script with parameters from php</p> <pre><code> ?&gt; &lt;form action="http://&lt;?=$_SERVER["SERVER_NAME"]?&gt;/index.php/search" method="GET" name="multiform"&gt; &lt;input type="submit" value="Back"&gt; &lt;? </code></pre> <p>This is one of the items in my table</p> <pre><code>echo "&lt;td class=\"cent\"&gt;&amp;nbsp;&lt;input type=\"checkbox\" name=\"rids[]\" value=\"{$reportdate}\"&gt;&amp;nbsp;&lt;/td&gt;"; </code></pre> <p>Here I am creating the button to be 'sent' to the javascript function - However I want to be able to send multiple items and I want to be able to send variables from PHP</p> <pre><code>echo"&lt;input type='submit' value='button text' onclick='return view_submit(650,'$reportGarb');' /&gt; "; </code></pre> <p>These are the items that need to be sent through to the next page - they should be filled out in the javascript function </p> <pre><code>echo "&lt;input type='hidden' name='edit' value='999'&gt;"; echo "&lt;input type='hidden' name='garcom' value='1'&gt;"; echo "&lt;/form&gt;"; </code></pre> <p>This is the function I call from my form submit - the second paramater doesnt get set</p> <pre><code>&lt;script&gt; function view_submit(subtype,garcom) { if (has_a_check(document.multiform["rids[]"]) == false) { alert("You must select some items!"); return false; } document.multiform.action='http://&lt;?= $_SERVER["SERVER_NAME"]?&gt;/index.php/search'; document.multiform.method='GET'; document.multiform["edit"].value = subtype; document.multiform["garcom"].value = garcom; return true; } &lt;/script&gt; </code></pre> <p>What I am seeing is a URL like this</p> <pre><code>"..com/search?rids%5B%5D=2013-05-01&amp;edit=999&amp;garcom=1 </code></pre> <p>So Is the way I am doing this the best way to do it, and why is the second parameter not being set to my variable that I pass to the js?</p> <p>If I remove the second parameter the edit becomes 650</p>
 

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