Python Forum
phython language java integration - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: phython language java integration (/thread-11332.html)



phython language java integration - jammytcs123123 - Jul-04-2018

I am attempting to submit a HTML form that has some values created via javascript. However, when I submit the form those input fields lose their values in favor of empty strings. What can I do to prevent the fields from dropping their new values upon hitting the submit button?

Form Code:

Output:
<form id="post-form" class="save-form" method="POST" action="/posts" style="display: none"> <input placeholder="Title" name="title" /><br> <input placeholder="Location" name="location" /></br> <input placeholder="Content" name="content" /><br> <input id="formlat" name="latitude" type="hidden" /> <input id="formlng" name="longitude" type="hidden" /> <input name="user_id" type="hidden" value="<%= current_user.id %>" /> <input type="submit" value="Submit"/> </form>
Relevant Javascript Code:

Output:
var newlat = newmarker.getPosition().lat(); var newlng = newmarker.getPosition().lng(); document.getElementById("formlat").value = newlat; document.getElementById("formlng").value = newlng;
Setting default values, or not setting them, always produces the same result: the form submits with "" for those fields (or whatever was inside value=""). However, the console shows that those fields are correctly being filled with their lat/long up until I hit the submit button, where they revert to their default values (in this case ""). It is only in rails' logs that I can see the fields are blank in the actual POST.


RE: phython language java integration - Skaperen - Jul-04-2018

if you set a default value, and it submits "" instead, then clearly it is not using that default value. have you followed the value through the code? what python code is involved with this?