Skip to content

Commit a927d92

Browse files
Update README.md
1 parent 7bd1073 commit a927d92

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

go/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
## How to work with WebForms Core in GO
22

3-
To use WebForms Core, first copy the WebForms class file in this directory to your project. Then create a new View file similar to the one below.
3+
To use WebForms Core, first copy the WebForms class file ("webforms.go") in this directory to "webforms" directory in your project. Then create a new View file ("main.go") similar to the one below.
4+
> Please make sure to replace "{your-project-name}" with project name in the import section.
45
56
```go
67
package main
78

89
import (
9-
"fmt"
10-
"net/http"
11-
"strconv"
10+
"fmt"
11+
"{your-project-name}/webforms"
12+
"net/http"
1213
)
1314

1415
func main() {
15-
http.HandleFunc("/", handleForm)
16-
http.ListenAndServe(":8080", nil)
16+
http.Handle("/script/", http.StripPrefix("/script/", http.FileServer(http.Dir("script"))))
17+
http.HandleFunc("/", handleForm)
18+
http.ListenAndServe(":8080", nil)
1719
}
1820

1921
func handleForm(w http.ResponseWriter, r *http.Request) {
20-
if r.Method == http.MethodPost {
21-
name := r.FormValue("txt_Name")
22-
backgroundColor := r.FormValue("txt_BackgroundColor")
23-
fontSize, err := strconv.Atoi(r.FormValue("txt_FontSize"))
24-
if err != nil {
25-
fontSize = 16
26-
}
22+
if r.Method == http.MethodPost {
23+
name := r.FormValue("txt_Name")
24+
backgroundColor := r.FormValue("txt_BackgroundColor")
25+
fontSize := r.FormValue("txt_FontSize")
2726

28-
form := new(WebForms)
27+
form := new(webforms.WebForms)
28+
ip := &webforms.InputPlace{}
2929

30-
form.setFontSize(InputPlace.tag("form"), fontSize)
31-
form.setBackgroundColor(InputPlace.tag("form"), backgroundColor)
32-
form.setDisabled(InputPlace.name("btn_SetBodyValue"), true)
30+
form.SetFontSize(ip.Tag("form"), fontSize+"px")
31+
form.SetBackgroundColor(ip.Tag("form"), backgroundColor)
32+
form.SetDisabled(ip.Name("btn_SetBodyValue"), true)
3333

34-
form.addTag(InputPlace.tag("form"), "h3")
35-
form.setText(InputPlace.tag("h3"), "Welcome "+name+"!")
34+
form.AddTag(ip.Tag("form"), "h3", "p")
35+
form.SetText(ip.Tag("h3"), "Welcome "+name+"!")
3636

37-
fmt.Fprint(w, form.response())
38-
return
39-
}
37+
fmt.Fprint(w, form.Response())
38+
return
39+
}
4040

41-
fmt.Fprint(w, `<!DOCTYPE html>
41+
fmt.Fprint(w, `<!DOCTYPE html>
4242
<html>
4343
<head>
4444
<title>Using WebForms Core</title>
@@ -71,4 +71,4 @@ As you can see, the WebFormsJS script has been added in the header section of th
7171

7272
The latest version of the WebFormsJS script is available through the link below.
7373

74-
https://github.com/elanatframework/Web_forms/blob/elanat_framework/web-forms.js
74+
https://github.com/elanatframework/Web_forms/blob/elanat_framework/web-forms.js

0 commit comments

Comments
 (0)