Example: JavaScript button to run a newLISP def?

A web framework in newLISP
Locked
kanen
Posts: 145
Joined: Thu Mar 25, 2010 6:24 pm
Contact:

Example: JavaScript button to run a newLISP def?

Post 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.
. Kanen Flowers http://kanen.me .

itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Re: Example: JavaScript button to run a newLISP def?

Post 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.
Last edited by itistoday on Fri Apr 02, 2010 3:30 pm, edited 1 time in total.
Get your Objective newLISP groove on.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Example: JavaScript button to run a newLISP def?

Post 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... :)

kanen
Posts: 145
Joined: Thu Mar 25, 2010 6:24 pm
Contact:

Re: Example: JavaScript button to run a newLISP def?

Post 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... :)
. Kanen Flowers http://kanen.me .

Locked