RadiantHex
RadiantHex

Reputation: 25557

HTML - How do I use a popup in order to input and output a value?

I see this pattern used very often!


Any idea how this works?

Edit:

by popup I mean an actual window popup, rather than a modal window. A modal window could work nicely though I reckon.

Upvotes: 0

Views: 3092

Answers (3)

Daniel Roseman
Daniel Roseman

Reputation: 599610

The only way to do this is with Javascript. Django's own admin includes a (fairly clunky) example: when you save the popup, it returns a response consisting of just a <script> tag containing Javascript which references the box in the parent form. See for example django.contrib.admin.options.ModelAdmin.response_add.

Upvotes: 1

Clyde Lobo
Clyde Lobo

Reputation: 9174

Do you want something like this ?

http://jqueryui.com/demos/dialog/#modal-form

http://jqueryui.com/demos/dialog/modal-form.html

You can validate the form with js / jquery and then do an ajax call and post the data to the server

Upvotes: 3

tiagoboldt
tiagoboldt

Reputation: 2426

You can use somethign like facebox to create the popup. This requests a page to the server (your form). Once submitted, detect that the facebox was closed (see the API) and make a new ajax request to the server that will return the needed data to populate your page.

Upvotes: 0

Related Questions