Anyone have any idea why my HTML form isn't submit...
# suitescript
u
Anyone have any idea why my HTML form isn't submitting values to Netsuite on POST? For context, I have created an html page where people can do data entry, and one element they requested was to be able to add new lines for Lot Numbers. I did so by making a
div
with the id "addme", then having a button that runs a function that adds a new element by running
document.createElement()
, then
.setAttribute()
, then finally
.appendChild()
on each element before it gets added to the div. As in the image, there are two text fields whose values I need to extract value from. Debugging from the Execution log though, I can only seem to get the value from the first textbox, with the other one not even registering. Everything has been able to push onto Netsuite (and the custom record is able to generate just fine), but the values from the last textbox just won't appear. Any and all ideas appreciated, thanks.
s
make sure your input elements have a name attribute. usually best to make it the same as the
id
with some sort of counter for each added element name ie.
<input type="text" id="lotnumber1" name="lotnumber1" class="form-control" required/>
u
i've added the
name
attribute with a similar value to the
id
attribute, yet it still won't push. for context, this is what the generated row looks like:
Copy code
<input id="lot0" type="text" name="lot0" style="height: 70px; width: 360…px; text-align: center;" placeholder="Lot Number..." required="">
i'm currently trying other things to get it to push through, like adding a
required
tag just for redundancy, but I'm drawing a blank. My last-ditch idea would be to merge the counter to the Lot Number and have a separator and just parse it when it enters back to the POST of the suitelet, though I'm still hoping someone out there has an idea.
s
do you have a form element with a method?
<form method="post">....</form>
u
yes, but not quite the same format as yours:
<form method="post" class="form-horizontal" action="...<http://netsuite.com|netsuite.com>...;deploy=1">
i've shrunked the action just in case, but it routes to a suitelet i've deployed. and yes, the entire html page is a form.
s
what is your submit action button/input?
u
<button type="submit" class="btn" style="width: 150px; height: 50px; font-size: 16px" formmethod="post">Submit to Netsuite</button>
s
Are you loading serverWidget?
m
use React with you'r html
s
The only difference i can see compared to a similar submission i have, is your submit button doesn't have an id. I wouldn't think that would have an impact, but you never know
and you don't need form method in the button, that will override the form setting.... perhaps it's ignoring the form action="..." method="post" since you've nominated the method in the button
u
after much trial and error as my overtime would allow, I've deduced the
disabled
attribute to be the reason why it wasn't getting sent. I added this so it would prevent user input in one of the fields (forcing them to use the counter buttons instead). I ended up resolving it by removing the attribute through an
onsubmit
function call from the
form
tag, since doing an
onclick
function call from the
submit
button didn't seem to register before the object was sent back to POST. thanks for taking the time to reply though! truly appreciated the extra input. @Marat I'll consider it for the next project, thanks. I've personally haven't learned it yet, but I'll definitely be reading up on it.
s
I find MDBootstrap Javascript really easy to work with in NS when not using N/ui/serverWidget