newLISP Fan Club

Forum => So, what can you actually DO with newLISP? => Dragonfly => Topic started by: kanen on March 31, 2010, 06:57:41 PM

Title: Example: JavaScript button to run a newLISP def?
Post by: kanen on March 31, 2010, 06:57:41 PM
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:


(define (Name your-name)
  (println "Hello: " your-name)
)


Seems simple, but my ant-like brain has not yet grok'd the fullness of Dragonfly.
Title: Re: Example: JavaScript button to run a newLISP def?
Post by: itistoday on April 01, 2010, 10:12:01 PM
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 (//http) documented (//http).
Title: Re: Example: JavaScript button to run a newLISP def?
Post by: cormullion on April 02, 2010, 02:05:45 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:


<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:


(set 'search-request ($POST "inputstring")

and somewhere in the 'search' view I've written there's this:


(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... :)
Title: Re: Example: JavaScript button to run a newLISP def?
Post by: kanen on April 02, 2010, 04:12:02 PM
Quote from: "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:


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.


Quote
....


<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:


(set 'search-request ($POST "inputstring")

and somewhere in the 'search' view I've written there's this:


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