Making a car spawn in html

im trying to add a search bar in html to send to lua so u can spawn any car you want from typing it in im am working on my own staff panel and i would like to add this if anyone can help

Add a nui callback in your Lua code using RegisterNUICallback() and then send from NUI a post request to http://resourcename/callbackname

For example

RegisterNUICallback("spawn", function(data, db)
    local car = data.car

    -- spawn car code
end)

and in NUI

// call this from a submit/onclick event or something
function spawnCar(car){
    // using jquery, you can also use fetch() if you dont like jquery
    $.post("http://resourcename/spawn", JSON.stringify({car: car}))
}

Hope this kinda helped, it should bring you to the right path
For more info about NUI callbacks check this topic [How-To] Use NUI (UI Creation with HTML)

<form action="http://resourcename/spawn">
  <input type="text" placeholder="Search.." name="search">
  <button type="submit"><i class="fa fa-search"></i></button><
/form>

@TheIndra so i added the nui callback and the js code but what do i add in html? i tried this code but no luck

Guess it won’t work with form post params, check for submit in javascript and then post a JSON string

how would i do that can you give me an example?

document.getElementById("#formdiv").onsubmit = function(e){
    const car = document.getElementsByName("search")[0].value
    
    // dont forget to change resourcename to your resource name lol
    fetch('http://resourcename/spawn', { method: "POST", 
        body: JSON.stringify({car: car}))
}

Something like this

for me that did not work unless im doing something wrong