<form action="{{=URL('credit_card_saved')}}" method="post" id="payment-form2">
<button>Submit</button>
</form>
<script>
function CustomizeFormSubmission2(event) {
event.preventDefault();
var form = document.getElementById('payment-form2');
var element = document.createElement('input');
element.setAttribute('type', 'hidden');
element.setAttribute('name', 'stripeToken');
element.setAttribute('value', "THIS_IS_TOKEN");
form.appendChild(element);
form.submit();
}
var form = document.getElementById('payment-form2');
form.addEventListener('submit', CustomizeFormSubmission2);
event.preventDefault();sorry for keeping posting about this. I am just totally stuck. I am sure that I am missing something very basic. Here is the complete code:<form action="{{=URL('credit_card_saved')}}" method="post" id="payment-form2">
<button>Submit</button>
</form>
<script>
function CustomizeFormSubmission2(event) {
event.preventDefault();
var form = document.getElementById('payment-form2');
var element = document.createElement('input');
element.setAttribute('type', 'hidden');
element.setAttribute('name', 'stripeToken');
element.setAttribute('value', "THIS_IS_TOKEN");
form.appendChild(element);
form.submit();
}
var form = document.getElementById('payment-form2');
form.addEventListener('submit', CustomizeFormSubmission2);
So when this is placed in the view straight - it's perfect. Behaves as expected.However, if it's placed into the component via LOAD, it grossly malfunctions. Not only the post_vars is empty, but evenevent.preventDefault();
doesn't work either (if I remove form.submit, it's still immediately submitting the form).What am I missing about how LOAD is expected to operate?? How do I make it work??
def index():
do_prep_stuff()
form = SQLFORM(db.mylist)
if form.process().accepted:
etc()
fi
return dict(form=form, getter=LOAD(url=URL(request,f="getstuff.load:),ajax=True))
topofpage
{{block left_sidebar}}
blah
{{end}}
{{=form}}
{{=getter}}
def getstuff():
form = SQLFORM.factory(Field('x'), Field('y'))
form.element("input, _id="no_table_x")['_autofocus'] = True
if form.process().accepted:
stuff_x = form.vars.x
etc()
fi
return dict(form=form)
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/dDzwFQlxl5w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/40e8b12a-a85d-4d96-8ff1-7d1839ad6634%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<form class="no_trap" ...>--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/dDzwFQlxl5w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/fab650af-3326-4a7b-a394-05eca5bb56ea%40googlegroups.com.