Syvill Posted September 13, 2019 Report Share Posted September 13, 2019 Hi all, I'm fairly new to javascript and I'm working on this frequent buyer website. What I'm trying to do is to submit the form multiple times base on user input. I have this code: <SCRIPT> document.addEventListener('BeforeFormSubmit', function (event) { var countx = document.querySelector('[id*=Purchase_count'); for (var i=1;i < countx.value;i++) { document.getElementById("caspioform").submit(); } }) </SCRIPT> Is there a reason why it's not working properly in google chrome but works fine on Edge? Here's my datapage: https://c1abc789.caspio.com/dp/3dca7000a203fdee67e14f3ebfa1 Feel free to submit some test records. Thanks in advance for any help I can get on this. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted September 13, 2019 Report Share Posted September 13, 2019 Using JS to have multi submit is not a good idea specifically if you have a number of for instance 15 ~ 20 or more. Instead you can get the Purchase_count from the form and have as triggered actions based on the source table which adds info for that many times you want to repeat this in your table. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted September 13, 2019 Report Share Posted September 13, 2019 If you explain what the form is for there might also be better ways Quote Link to comment Share on other sites More sharing options...
MayMusic Posted September 13, 2019 Report Share Posted September 13, 2019 The source of the submission is different from where you get all rows. There are 3 tables here. One is QTY which has one Integer field holding 1 to 50. Two same tables MultiSubmit and MutliSubmitDetails. Submission is based on MultiSubmit and MutliSubmitDetails are having all rows including the initial row. Syvill 1 Quote Link to comment Share on other sites More sharing options...
Syvill Posted September 13, 2019 Author Report Share Posted September 13, 2019 I totally forgot about the triggered actions! Thanks for reminding me. I'll explore into that. Anyway, the max limit they can submit is 12 per submission. Kinda like a card they need to fill in. Once they have 12 purchases they get a free product. Quote Link to comment Share on other sites More sharing options...
Glitch Posted September 13, 2019 Report Share Posted September 13, 2019 If you want the maximum submission to be just 12, then you can just set the fields inside the QTY field to 12. The inner join you see up there in the select will serve as the loop that while the QTY is greater than or equal to a certain value, then, continue adding the field. Syvill 1 Quote Link to comment Share on other sites More sharing options...
Syvill Posted September 17, 2019 Author Report Share Posted September 17, 2019 Here is what I'm trying to do: Right now, it's working just fine but without the Qty field. The user will have to enter the the purchases one by one. With the Qty field, I got that working with javascript (only works in Edge for some reason). I tried your triggered action sample, I think it's adding purchases depending on the number in the Qty Table? or I might've missed something. Below is what I'm trying to do. My logic is it will add entries if the count of entries that have the same Purchase_ID is less than the #inserted.Qty. I can't seem to make it work. Am I doing it wrong? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.