0👍
✅
Finally figured out what was causing the issue. The DOM was not finished rendering the JSON Schema Form before the script was executing to call
var project_selection = document.getElementsByName("form[project]");
therefore wrapping the above script in a jquery ready function fixed the issue.
<script>
$('document').ready(function(){
var project_selection = document.getElementsByName("form[project]");
console.log(project_selection);
console.log(project_selection[0]);
});
</script>
see more at: Javascript HTML collection showing as 0 length
2👍
Not entirely sure on this one, but you are using
getElementsByClassName
, which is relevant to the class name of the element. Not the name. So for example:
<div class="cname"></div>
That is a class name, form elements have a name
attribute that you can query via
var project_selection = document.getElementsByName("form[project]");
- [Django]-How to adding middleware to Appengine's webapp framework?
- [Django]-Django not loading CSS?
- [Django]-How to connect to a postgres database in a docker container?
- [Django]-Help with complex join in Django ORM
- [Django]-Celery periodic task doesn't start
Source:stackexchange.com