0

i was searching for passing html value as a parameter on golang fiber but still got no answers.

javascript:

function monthPicker() {
    console.log(document.getElementById("datePicker").value);
    var date = document.getElementById("datePicker").value;
    var d = {{.data.GetWeek date}};
    console.log(d)
}

viewdata function:

func (v ViewData) GetWeek(date string) int {
    n, err := time.Parse("2006-01", date)
    if nil != err {
        return 0
    }

    _, week := n.ISOWeek()

    return week
}
Poala Astrid
  • 1,028
  • 2
  • 10
Beruangs
  • 9
  • 3
  • From the description of the problem it isn't immediately clear what you are trying to achieve. I am going to try to guess. Are you looking to create a handler in go/fiber and then call this handler from Javascript code? – jabbson Jul 05 '22 at 02:42
  • It looks like you are trying to call a method from a Go template. This would work if you passed the correct `.data` object to the template execution. Show how you are evaluating that template. – Burak Serdar Jul 05 '22 at 04:19
  • this way how i define my viewdata ``` type ViewData struct { Chart *AdministrationChartData MonthlyGraph *AdministrationChartData } func (v ViewData) GetWeek(date string) int { n, err := time.Parse("2006-01", date) if nil != err { return 0 } _, week := n.ISOWeek() return week } ``` – Beruangs Jul 05 '22 at 06:08

0 Answers0