Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Jeremy Reimer

#16
Thanks, it was ($GET) that I was looking for.  I wanted to make a multi-select box and return all elements the user checked.  You were exactly right, I needed to add "[]" to each "input" element, so that I could get back the whole thing as a list.  



So now I have



(define (multi-select-box inputlist)
(let (a "")
(extend a "<form action='multi-select-submit.cgi'")
(dolist (x inputlist)
(extend a "<input type='checkbox' name='input[]' value='" (string x) "'>" (string x) "<br>"))
(extend a "<input type='submit' value='Submit'>")
(extend a "</form>")
a))


and in multi-select-submit.cgi I have:



(println "<br>GET info: " ($GET "input[]"))


And the answer it returns is a list of checked elements, eg: GET info: ("element" "name" "date" "data")



This is exactly what I wanted! Thanks so much!
#17
Hi folks,



I'm trying to build a field selector in newLISP.  Right now I have the code:



(define (multi-select-box inputlist)
(let (a "")
(extend a "<form action='multi-select-submit.cgi'")
(dolist (x inputlist)
(extend a "<input type='checkbox' name='input' value='" (string x) "'>" (string x) "<br>"))
(extend a "<input type='submit' value='Submit'>")
(extend a "</form>")
a))


What this function does is return a string that creates a multi-select HTML form (with checkboxes) based on a list.  This string can then be printed to the web page.  When the user clicks "Submit", it redirects to a URL like this one:



http://localhost:8080/multi-select-submit.cgi?input=document&input=element">http://localhost:8080/multi-select-subm ... ut=element">http://localhost:8080/multi-select-submit.cgi?input=document&input=element



Now, from that URL I can probably extract the form values input=document and input=element.  But I'm not sure how to get the current URL in the first place.  



I am using newLISP and Dragonfly to serve the web pages.



Thanks for any help you can provide!
#18
This totally worked!  Thanks so much for your quick reply!
#19
Hello!  I'm just getting started with newLISP, and I really like it a lot.  Forgive the newbie questions.



I have a test XML file called dingy.xml that looks like this:



<document>
<element name="First" date="4/23/2010">
  <data>This is the first element</data>
</element>
<element name="Second" date="4/23/2010">
  <data>This is the second element</data>
</element>
</document>


I am parsing with xml-parse using this code:



(define (parse-xml-data str)
  (xml-type-tags nil nil nil nil)
  (let ((xml (xml-parse str 15)))
       (or xml (throw-error (xml-error)))))

  (setq parsedlist (parse-xml-data (read-file "./dingy.xml")))


This returns an s-xml list as follows:



((document (element ((name "First") (date "4/23/2010")) (data "This is the first element")) (element ((name "Second") (date "4/23/2010")) (data "This is the second element"))))



Now, I am able to search and retrieve, say, all items with the type "data" using this code:



(dolist (el (ref-all 'data parsedlist))
         (println (rest (parsedlist (chop el)))))


This gives me back the following result:



("This is the first element")



("This is the second element")



This is great!  But now my question is this:  how could I find all the "field names" (I don't know how better to describe it) without knowing them beforehand?  In this XML example, I have a type called "data", which I pass into ref-all by quoting it; 'data.  But what if I just want to get a list of all possible elements I could search for?  In other words, how could I get a list back that looks like this:



((document) (name) (date) (element) (data))



which is all the different types of element names (field names?) in my XML?  My goal for this is to be able to input in any kind of XML file and return back a list of searchable "field names".



In the newLISP introductory guide, it says (pg 156):


Quote
You add them up to get the options code number – so 15 (+ 1 2 4 8) uses the first four of these options: suppress unwanted stuff, and translate strings tags to symbols.  As a result of this, new symbols have been added to newLISP's symbol table:



(channel description docs item lastBuildDate link managingEditor rss sxml title version webMaster xml)



These correspond to the string tags in the XML file, and they'll be useful almost immediately.


I guess what I'm looking for is some way to bring back a list of all the symbols that have been added to the symbol table when I use xml-parse.  I wish I could have explained it better.  :)



Thanks so much for any help you can provide!