DesiLogi Posted July 15, 2016 Report Share Posted July 15, 2016 I'm trying to figure out how to use a concatenate function that works in a submission form for a tabular inline insert. I believe Ajax has to be disabled for this (I did that). I have the below in a custom.js file accessible by the page the datapage is hosted in: //concate for the simple combination field function f_secondcombination(part1, part2, comb){ $("[name='"+comb+"']").val($("[name='"+part1+"']").val()+"_"+$("[name='"+part2+"']").val()); } In the datapage itself I'm using, in the header: <div id="cb_sup"> In the footer of the datapage: </div> <script> $("#cb_sup form”).click(function(){ f_secondcombination('InsertEditRecordCompanyID', 'InsertEditRecordArea', 'InsertEditRecordCompanyID_Area'); }); $(document).ready(function(){ var v_errmes = "This Area already exists for this Company. Please provide a different one."; f_modify_err_message("cb_value_present", "cb_not_valid_info",v_errmes); }); </script> The other solution I'm trying is having only this (so it's not referencing the custom.js file) in the footer: <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var CompanyID = document.getElementById("InsertEditRecordCompanyID").value; var Area = document.getElementById("InsertEditRecordArea").value; var CompanyID_Area = CompanyID + Area; document.getElementById("InsertEditRecordCompanyID_Area").value = CompanyID_Area; } document.getElementById("caspioform").onsubmit=concatenate; </SCRIPT> Neither of these is working: When the user adds a new record (in inline insert) it should combine the 'CompanyID' field with the 'Area' field and put that in 'CompanyID_Area' (which will be a unique field in the table so duplicates can be checked). If someone can please help troubleshoot this I'd very much appreciate it. Quote Link to comment Share on other sites More sharing options...
kRv Posted July 18, 2016 Report Share Posted July 18, 2016 Hello DesiLogi, I cannot check your script right now, so it is just my opinion. I think that your script does not works, because you use invalid names for inline fields. Please pay your attention, that prefix for inline insert fields is InlineAdd, and for inline update it is InlineEdit, but it isn't InsertRecord. Thanks Quote Link to comment Share on other sites More sharing options...
DesiLogi Posted July 18, 2016 Author Report Share Posted July 18, 2016 Hi kRv, Ok thanks for pointing that out. Someone at Caspio gave me the prefixes specifically several months ago when I first tried this- that's why I was using them. But it makes sense they should be different. I'll give that a shot and post if I get it working this way. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 18, 2016 Report Share Posted July 18, 2016 I m not sure about the first code but for the second one try: <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var CompanyID = document.getElementsByName("InlineAddCompanyID")[0].value; var Area = document.getElementsByName("InlineAddArea")[0].value; var CompanyID_Area = CompanyID + Area; document.getElementsByName("InlineAddCompanyID_Area")[0].value = CompanyID_Area; } document.getElementById("Mod0InlineAdd").onclick=concatenate; </SCRIPT> Put this code in HTML Block at the end of all elements. Quote Link to comment Share on other sites More sharing options...
DesiLogi Posted July 19, 2016 Author Report Share Posted July 19, 2016 Hi MayMusic, Thanks for the help with the code. I've tried it but am getting an error message for the combined field CompanyID_Area. This is the 'Unique' field in the table and it has to be on the datapage results in order to allow Inline Add. I've attached the error message- perhaps the js needs to run before the 'Add' button is clicked? Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 20, 2016 Report Share Posted July 20, 2016 I tried this code and it worked for me <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var CompanyID = document.getElementsByName("InlineAddRed")[0].value; var Area = document.getElementsByName("InlineAddGreen")[0].value; var CompanyID_Area = CompanyID + Area; alert(CompanyID_Area ); document.getElementsByName("InlineAddallcolor")[0].value = CompanyID_Area; } document.getElementById("Mod0InlineAdd").onclick=concatenate; </SCRIPT> vanderLeest and Greg28 1 1 Quote Link to comment Share on other sites More sharing options...
DesiLogi Posted July 26, 2016 Author Report Share Posted July 26, 2016 Actually, I just got it to work finally. The problem is that Ajax has to be disabled and that takes away a lot of functionality on the datapage so it's a real trade off as to whether it's worth it. But thanks very much for your help on this. If anyone needs the final code I used (so they can modify it for themselves, it's below. <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var CompanyID = document.getElementsByName("InlineAddCompanyID")[0].value; var Area = document.getElementsByName("InlineAddArea")[0].value; var CompanyID_Area = CompanyID+"_"+Area; alert(CompanyID_Area ); document.getElementsByName("InlineAddCompanyID_Area")[0].value = CompanyID_Area; } document.getElementById("Mod0InlineAdd").onclick=concatenate; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 26, 2016 Report Share Posted July 26, 2016 Thank you for updating. The "alert(CompanyID_Area);" is to make sure value is concatenated. It can be removed. 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.