Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle App Engine Datastore - key value passing in HTML to js function
    text
    copied!<p>Using Jinja2 GAE Datastore.<br> In my template html javascript script section - I want to call a function triggered by onclick and pass 2 arguments. The second argument is a GAE key value. It seems the key is retrieved but then when it is passed as an argument - I get an uncaught reference error undefined - almost seems like it views it as an undefined variable?</p> <pre><code>html_output += "&lt;input class='filter_submit first_level' name='first_input' type='button' onclick='pass_hidden(1,{{one.key()}})' value='{{one.name1}}'&gt;&lt;/input&gt;&lt;br /&gt;"; </code></pre> <p>HERE IS THE FUNCTION CALLED BY THE ONCLICK...</p> <pre><code>function pass_hidden(num,key_val) { alert('in pass_hidden function'); var add_html; if (num=='1') { add_html += "&lt;input type='hidden' value='key_val' name='second_input'&gt;&lt;/input&gt;&lt;input type='hidden' value='1' name='heading_number'&gt;&lt;/input&gt;"; } else if (num=='2') { add_html +="&lt;input type='hidden' value='key_val' name='second_input'&gt;&lt;/input&gt;&lt;input type='hidden' value='2' name='heading_number'&gt;&lt;/input&gt;"; } else if (num=='3') { add_html +="&lt;input type='hidden' value='key_val' name='second_input'&gt;&lt;/input&gt;&lt;input type='hidden' value='3' name='heading_number'&gt;&lt;/input&gt;"; } add_html +="&lt;input type='hidden' name='heading_type' value='subject'&gt;&lt;/input&gt;"; /*$("hidden_inputs").append(add_html); */ document.getElementById("hidden_inputs").innerHTML = add_html; document.userchoices.submit(); } </code></pre>
 

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