Page 1 of 1
Example: JavaScript button to run a newLISP def?
Posted: Thu Apr 01, 2010 1:57 am
by kanen
Using Dragonfly;
I am interested in having a user enter some text into a box and then have them click a button which will perform a newLISP def and return some results.
For example:
(your-name input box) Name: | John |
(JavaScript button) Submit
When the user clicks submit, it runs:
Code: Select all
(define (Name your-name)
(println "Hello: " your-name)
)
Seems simple, but my ant-like brain has not yet grok'd the fullness of Dragonfly.
Re: Example: JavaScript button to run a newLISP def?
Posted: Fri Apr 02, 2010 5:12 am
by itistoday
With regards to forms Dragonfly is very similar to PHP. Use the $POST or $GET contexts to retrieve values from forms.
These contexts/dictionaries are
well documented.
Re: Example: JavaScript button to run a newLISP def?
Posted: Fri Apr 02, 2010 9:05 am
by cormullion
As he said.
I don't know how you would do a JavaScript button, but I have used the standard forms technique to get information for processing. On my blog page, there's a search form. The code for it is this:
Code: Select all
<div class="form">
<form id="search" action="search" method="POST" />
<p>
<input type="text" class="input" name="inputstring" size="8" value="" />
<input type="submit" name="search" value="Search">
</p>
</form>
</div>
Somewhere in the
route I've written for this page is this:
Code: Select all
(set 'search-request ($POST "inputstring")
and somewhere in the 'search'
view I've written there's this:
Code: Select all
(find-text 'blog-posts Route.Blog:search-request 1)
which does the searching.
I'm not saying this is how you should do it, just how I do it... :)
Re: Example: JavaScript button to run a newLISP def?
Posted: Fri Apr 02, 2010 11:12 pm
by kanen
cormullion wrote:As he said.
I don't know how you would do a JavaScript button, but I have used the standard forms technique to get information for processing. On my blog page, there's a search form. The code for it is this:
Thanks for your more polite response to my question. I am not an HTML/JavaScript coder by design, so the machinations of such a thing are kludgy to me.
Your response is the seed I needed to understand putting this into a newLISP context and making it work.
Groove.
....
Code: Select all
<div class="form">
<form id="search" action="search" method="POST" />
<p>
<input type="text" class="input" name="inputstring" size="8" value="" />
<input type="submit" name="search" value="Search">
</p>
</form>
</div>
Somewhere in the
route I've written for this page is this:
Code: Select all
(set 'search-request ($POST "inputstring")
and somewhere in the 'search'
view I've written there's this:
Code: Select all
(find-text 'blog-posts Route.Blog:search-request 1)
which does the searching.
I'm not saying this is how you should do it, just how I do it... :)