B4J Question Cannot get Data from a form which was working

Peter Lewis

Well-Known Member
Licensed User
Longtime User
Hi,
I have been looking for a few hours why this worm will not save data.
I checked on the HTML side and it looks perfect. How I did this was to past the form to https://httpbin.org/post
The result is

When I post to the server, I can see the length is different depending on what I type


But the map is not filled. I used this code to read it before and populate the DB

B4X:
    Dim query As String = utils.prepareInsertQuery($"
    INSERT INTO [ledposter].[dbo].[malls](
     [mallID]
    ,[mallName]
    ,[province]
    ,[city]
    ,[postalcode]
    ,[phone]
    ,[email]
    ,[ownerID]
    ,[suburb]
    ,[description]
    ,[retailshops]
    ,[posters]
    ,[status]
      ,[mtraffic]
 
            )"$)
    
    Dim guidST As JavaObject
    guidST.InitializeStatic("java.util.UUID")
    Dim guid As JavaObject = guidST.RunMethod("randomUUID",Null)
    Dim guidStr As String = guid.RunMethod("toString",Null)
    
        Dim params(query.Length - query.Replace("?","").Length) As String
    params(0) = guidStr
    params(1) = req.GetParameter("mallnameInput")
    params(2) = req.GetParameter("provinceSelect")
    params(3) = req.GetParameter("municipalitySelect")
    params(4) = req.GetParameter("postalcodeInput")
    params(5) = req.GetParameter("phoneInput")
    params(6) = req.GetParameter("emailInput")
    params(7) = req.GetParameter("ownerSelect")
    params(8) = req.GetParameter("suburbSelect")
    params(9) = req.GetParameter("descriptionTextarea")
    params(10) = req.GetParameter("retailshopsInput")
    params(11) =req.GetParameter("postersInput")
    params(12) = "unknown"
    params(13) ="0"
 
    sql.execnonquery2(query,params)

It seems like the data is coming through but I cannot find the method of extracting it

<form method="POST" action="/malladd">
</form>

Maybe it is a Sunday problem.

I am using HTMX to swap out the Select Areas and also to SWAP out the Searchable Fields.. I tried Choices.js but found it was not working for me as I had more than one field to use the plugin and it would not support that. So I eventually used datatables



B4X:
                                    <div class="col-lg-4">
                                                                            <label for="provinceSelect">Province</label>
                                                                            <br>
                                            <input list="provinceSelectlist" name = "provinceSelect" autocomplete="nope" hx-get="/muni"  hx-target="#municipalitySelectlist" placeholder="Search Province">               
                                                                            <datalist id="provinceSelectlist">
                                                                                  <#list  provincetable as provincetables>
                                                                                        <option value="${provincetables.province}" >
                                                                                  </#list>
                                                                            </datalist>
                                                                                    
                                                                            
                                                                        </div>
                                                                                            
                                                        <!-- State -->
                                                                        <div class="col-lg-4">
                                                                        <label for="municipalitySelect">Municipality</label>
                                                                        <br>
                                                                        <input list="municipalitySelectlist" name = "municipalitySelect"  autocomplete="nope" hx-get="/suburb"  hx-target="#suburbSelectlist" placeholder="Search Municipality">
                                                                                
                                                                            <datalist id="municipalitySelectlist">
                                                                                    <#list  municipalitytable as municipalitytables>
                                                                                        <option value="${municipalitytables.city}">
                                                                                    </#list>
                                                                            </datalist>
                                                                                
                                                                            
                                                                        </div>
                                                                        
                                                                        <div class="col-lg-4">
                                                                            <label for="suburbSelect">Suburb</label>
                                                                            <br>
                                                                            <input list="suburbSelectlist" name = "suburbSelect" autocomplete="nope" placeholder="Search Suburb">
                                                                                <datalist id="suburbSelectlist">
                                                                                            <#list  suburbtable as suburbtables>
                                                                                                <option value="${suburbtables.suburb}" >
                                                                                            </#list>
                                                                                </datalist>
                                                                        </div>



Thank you
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…