    [:input {:type "button" :value "Save"
             :class "btn btn-primary" :on-click save}]
    ])
+
+(defn get-update-documents-formdata []
+  {
+   :id (getinputvalue "id")
+   :documentname (getinputvalue "upd_documentname")
+   :title (getinputvalue "upd_title")
+   :employeename (getinputvalue "upd_employeename")
+   :date (getinputvalue "upd_date")
+   :location (getinputvalue "upd_location")
+   })
+
+
+
+(defn click-update[id]
+  (.assign js/location (str "#/documents/update/" id)))
+
+
+(defn docupdate [event]
+  (let [onres (fn[data]
+                (.assign js/location "/"))]
+    (http-post "http://localhost:8193/documents/update"
+               onres (JSON/stringify (clj->js (get-update-documents-formdata))))))
+
 
 (defn document-update-template [id dmt]
   [:div.form-group {:id "update" :class "form-group"}

            :class "btn btn-primary" :on-click docupdate}]])



(defn getinputvalue[id]
  (.-value (.getElementById js/document id)))

(defn get-documents-formdata []
  {:documentname (getinputvalue "documentname")
   :title (getinputvalue "title")
   :employeename (getinputvalue "employeename")
   :date (getinputvalue "date")
   :location (getinputvalue "location")
   })

(defn get-update-documents-formdata []
  {
   :id (getinputvalue "id")
   :documentname (getinputvalue "upd_documentname")
   :title (getinputvalue "upd_title")
   :employeename (getinputvalue "upd_employeename")
   :date (getinputvalue "upd_date")
   :location (getinputvalue "upd_location")
   })

(defn save [event]
  (let [onres (fn[data] (set! (.-location js/window) "http://localhost:8193"))]
    (http-post "http://localhost:8193/documents/add"
               onres  (JSON/stringify (clj->js (get-documents-formdata))))))

(defn click-update[id]
  (.assign js/location (str "#/documents/update/" id)))


(defn docupdate [event]
  (let [onres (fn[data]
                (.assign js/location "/"))]
    (http-post "http://localhost:8193/documents/update"
               onres (JSON/stringify (clj->js (get-update-documents-formdata))))))


(defn delete[id]
  (let [onres (fn [json]
                ((reset! documents (getdata json))
                 (r/render [render-documents @documents]
                           (.-body js/document))))]
    (http-delete (str "http://localhost:8193/documents/delete/" id) onres)))


(defn render-documents [documents]

                           [:td (.-documentname dn)]
                           [:td (.-title dn)]
                           [:td (.-employeename dn)]
                           [:td  (f/unparse (f/formatter "dd-MMM-yyyy")(f/parse (.-date dn)))]
                           ;; [:td (.-date dn)]
                           [:td (.-location dn)]
                           [:td [:input {:type "button" :on-click #(click-update(.-id dn))
                                         :value "Update"}]]
