Thanks for the reply. I apologize for the the posting of the code. I had enough of a difficult time, just getting my first post to publish.
I have made some incremental progress. I fixed the issue with the submit button not going to the route. That actually turned out to be formatting in my pug file such that the form was not closing properly.
I have 2 primary issues at the moment. I'll try to post code at the bottom
when i render scores/keepscore, i pass the course name and i have that displaying in my table as a header. However, this is not passing back to my /scores/update route.
This leads me to my second issue, when i pass the table to /scores/update and take a look at my sql statement, i can see that all the table elements are appearing at once. So i know that i need to look through the table, but i'm not sure how to accomplish this.
Thanks for any help you can provide.
form(method="post", action=form_action)
table
thead
tr
th: b Course #{result}
tr
th: b Name
th: b 1
th: b 2
th: b 3
th: b 4
th: b 5
th: b 6
th: b 7
th: b 8
th: b 9
th: b 10
th: b 11
th: b 12
th: b 13
th: b 14
th: b 15
th: b 16
th: b 17
th: b 18
th: b Total
tbody
- for(x=1;x<7;x++)
tr
td: b <input type="text" name = "GOLFER" size="25"/>
td: b <input type="number" name = "PAR1" min="1" Max="10"/>
td: b <input type="number" name = "PAR2" min="1" Max="10"/>
td: b <input type="number" name = "PAR3" min="1" Max="10"/>
td: b <input type="number" name = "PAR4" min="1" Max="10"/>
td: b <input type="number" name = "PAR5" min="1" Max="10"/>
td: b <input type="number" name = "PAR6" min="1" Max="10"/>
td: b <input type="number" name = "PAR7" min="1" Max="10"/>
td: b <input type="number" name = "PAR8" min="1" Max="10"/>
td: b <input type="number" name = "PAR9" min="1" Max="10"/>
td: b <input type="number" name = "PAR10" min="1" Max="10"/>
td: b <input type="number" name = "PAR11" min="1" Max="10"/>
td: b <input type="number" name = "PAR12" min="1" Max="10"/>
td: b <input type="number" name = "PAR13" min="1" Max="10"/>
td: b <input type="number" name = "PAR14" min="1" Max="10"/>
td: b <input type="number" name = "PAR15" min="1" Max="10"/>
td: b <input type="number" name = "PAR16" min="1" Max="10"/>
td: b <input type="number" name = "PAR17" min="1" Max="10"/>
td: b <input type="number" name = "PAR18" min="1" Max="10"/>
td: b <output type="number" name = "HOLETOT"/>
p <input type="submit" name="save"
It's pronounced Diane. I do data architecture, operations, and backend development. In my spare time I maintain Massive.js, a data mapper for Node.js and PostgreSQL.
When a form posts back, it only sends the values of named inputs (and selects and textareas etc). Everything else, including your table, is just static content. So if you want the course to be available in the update route, you need an input to hold that information. You can use the "hidden" input type to ensure the user doesn't have to see it.
I'm not really following what you're trying to say with the second issue. Remember your HTML table doesn't exist as far as the update route is concerned: it only cares about what's in those inputs, and those get parted out to fields in req.body automatically. Your SQL statement looks correct at a glance, although with NC is new to me -- wait, is this DB2 syntax?!
I do see a clearer picture when i output req.body to the console, however, i cannot figure out how to process it . Apparently i cannot iterate through it, which means i need to do something with it so that i can iterate.
just a snipped of the req.body
It's pronounced Diane. I do data architecture, operations, and backend development. In my spare time I maintain Massive.js, a data mapper for Node.js and PostgreSQL.
req.body is a hash, not an array. You can't iterate it, but you shouldn't need to. If you want the scores for the fifth hole, for example, that's req.body.PAR5 based on how you've named your input elements. That is an array since you have multiple inputs named PAR5, so Mike's score should be req.body.PAR5[0].
Unfortunately, i don't find much time to work on this, but today i got back to it and found a problem. I don't know if it is an issue i have to deal with because of HTML or because of body.parser.
I have a golf course named 'Highland Park'
i pass the course in as result in my .pug file and it displays properly.
I then have a hidden field in my body for the course name
td: b <input type="hidden" name = "COURSE" value= #{result}
when i process my hash, course shows as 'Highland'
it doesn't appear to be a size issue, but something to do with the space.
If i change the course name to 'HighlandPark', my hash shows 'HighlandPark'
Hope that makes sense.
Any idea how to handle this?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the reply. I apologize for the the posting of the code. I had enough of a difficult time, just getting my first post to publish.
I have made some incremental progress. I fixed the issue with the submit button not going to the route. That actually turned out to be formatting in my pug file such that the form was not closing properly.
I have 2 primary issues at the moment. I'll try to post code at the bottom
when i render scores/keepscore, i pass the course name and i have that displaying in my table as a header. However, this is not passing back to my /scores/update route.
This leads me to my second issue, when i pass the table to /scores/update and take a look at my sql statement, i can see that all the table elements are appearing at once. So i know that i need to look through the table, but i'm not sure how to accomplish this.
Thanks for any help you can provide.
When a form posts back, it only sends the values of named
input
s (andselect
s andtextarea
s etc). Everything else, including your table, is just static content. So if you want the course to be available in the update route, you need an input to hold that information. You can use the "hidden" input type to ensure the user doesn't have to see it.I'm not really following what you're trying to say with the second issue. Remember your HTML table doesn't exist as far as the update route is concerned: it only cares about what's in those
inputs
, and those get parted out to fields inreq.body
automatically. Your SQL statement looks correct at a glance, althoughwith NC
is new to me -- wait, is this DB2 syntax?!Yes, this is DB2 systax. NC is No Commit. It is used when the database is not journaled.
I have been chasing down processing the req.body all day without luck.
to explain what i meant with my second issue, take a look at the following. I have entered 1 golfer and his score
I do see a clearer picture when i output req.body to the console, however, i cannot figure out how to process it . Apparently i cannot iterate through it, which means i need to do something with it so that i can iterate.
just a snipped of the req.body
req.body
is a hash, not an array. You can't iterate it, but you shouldn't need to. If you want the scores for the fifth hole, for example, that'sreq.body.PAR5
based on how you've named your input elements. That is an array since you have multiple inputs namedPAR5
, so Mike's score should bereq.body.PAR5[0]
.I was close.
The example i came across,showed req.body[0].PAR5
thanks for the help.
Unfortunately, i don't find much time to work on this, but today i got back to it and found a problem. I don't know if it is an issue i have to deal with because of HTML or because of body.parser.
I have a golf course named 'Highland Park'
i pass the course in as result in my .pug file and it displays properly.
I then have a hidden field in my body for the course name
td: b <input type="hidden" name = "COURSE" value= #{result}
when i process my hash, course shows as 'Highland'
it doesn't appear to be a size issue, but something to do with the space.
If i change the course name to 'HighlandPark', my hash shows 'HighlandPark'
Hope that makes sense.
Any idea how to handle this?