Example: JavaScript button to run a newLISP def?

Started by kanen, March 31, 2010, 06:57:41 PM

Previous topic - Next topic

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:


(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[/url] .

itistoday

#1
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 http://www.rundragonfly.com/dragonfly_getpost">well http://www.rundragonfly.com/dragonfly_api">documented.
Get your Objective newLISP groove on.

cormullion

#2
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... :)

kanen

#3
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... :)
. Kanen Flowers http://kanen.me[/url] .