Example: JavaScript button to run a newLISP def?

A web framework in newLISP

Example: JavaScript button to run a newLISP def?

Postby kanen » Thu Apr 01, 2010 1:57 am

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 .
kanen
 
Posts: 144
Joined: Thu Mar 25, 2010 6:24 pm

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

Postby itistoday » Fri Apr 02, 2010 5:12 am

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.
itistoday
 
Posts: 413
Joined: Sun Dec 02, 2007 5:10 pm
Location: I'm sitting right next to you. :)

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

Postby cormullion » Fri Apr 02, 2010 9:05 am

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... :)
cormullion
 
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W

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

Postby kanen » Fri Apr 02, 2010 11:12 pm

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 .
kanen
 
Posts: 144
Joined: Thu Mar 25, 2010 6:24 pm


Return to Dragonfly

Who is online

Users browsing this forum: No registered users and 1 guest

cron