import wixData from 'wix-data'; {}
//
exportfunction button38_click(event) {
//Add your code for this event here:
let toInsert = {
"mobil": $w("#input5").inputType,
"idMobil": $w("#input6").inputType,
"subRental": $w("#input10").inputType,
"lokasiRental" : $w("#input11").inputType,
};
wixData.insert("HasilFormulir", toInsert)
.t
hen( (results) => {
let item = results; //see item below
} )
.catch( (err) => {
let errorMsg = err;
} );}
Hello Gund Rock,
perhaps you are searching for ...
import wixData from 'wix-data'; {} exportfunction button38_click(event) { //Add your code for this event here: let toInsert = { "mobil": $w("#input5").value, "idMobil": $w("#input6").value, "subRental": $w("#input10").value, "lokasiRental" : $w("#input11").value, }; wixData.insert("HasilFormulir", toInsert) .t hen( (results) => { let item = results; //see item below } ) .catch( (err) => { let errorMsg = err; } );}
But i don't know if this is the right solution, because this will create a new datarow.
An alternativ option could be the following.....
$w("#myDataset").setFieldValues( { "title": "New Title", "name": "New Name" } ); $w("#myDataset").save();
help me please :(
Why #datepicker and #uploadbutton unable input to dataset ?
exportfunction dataset1_ready() {
//Add your code for this event here:
$w("#dataset1").onBeforeSave( () => {
$w("#dataset1").setFieldValues( {
"mobil": $w("#text155").text,
"statusSewa": $w("#dropdown1").value,
"pernahAtauBelumPernah": $w("#radioGroup2").value,
"namaLengkap": $w("#input9").value,
"tanggalSewa" : $w("#datePicker3").value,
"eKtp" : $w("#uploadButton1").value,
"idCard" : $w("#uploadButton2").value,
"stnk" : $w("#uploadButton3").value,
} )} );}
@Ahmad @russian-dima
Thanks u very much for all of you people, it's work perfect. yeargh!
Sorry this way is not possible!
Sorry if I make a mistake on my project before...
I'll give you my code, so you can understand what I mean...
hopefully you can help me to fix this... hihihihi :)
https://editor.wix.com/html/editor/web/renderer/edit/7b0f8492-efb5-4501-9a54-73fa4ab9eacc?metaSiteId=eaf5d0fa-b2e8-490b-bfa6-c79273ad8cf6&editorSessionId=5ff2bde3-ec0c-48a3-a69d-ec5e54887e75&referralInfo=dashboard
Hi,
Why you're inserting data from a form that's already connected to a dataset?
You can just set the fields value before save and you're good to go.
If the button is connected to the dataset, you only need to create a onBeforeSave() function on the dataset.
$w("#myDataset").onBeforeSave( () => { $w("#myDataset").setFieldValues( { "mobil": $w("#input5").value, "idMobil": $w("#input6").value, "subRental": $w("#input10").value, "lokasiRental": $w("#input11").value, } ) } );
And by the way, why do you need the inputType ?? I think what you want is the value of the input field.
If the button is not connected to a dataset (Write or Read/Write), just place this code inside the page's onReady() function:
$w('#saveButton').onClick((event) => { $w('#myDataset').save(); })
Hope that helped~!
Ahmad
thanks for fever. I'm sorry, I failed to implement the alternative, but I changed #input to #text and it worked.
and now there is another new problem. I use the function to the button that has been filled with other functions. in other words "2 export function button click (double function on one button36_click)
////////////////////////////////////////////////////// export function button36_click(event) { //Add your code for this event here: const sewaValid = $w("#dropdown1").required = true; const namaValid = $w("#input26").required = true; const tanggalsewaValid = $w("#datePicker3").required = true; const jamsewaValid = $w("#timePicker3").required = true; const durasihariValid = $w("#dropdown12").required = true; const isFormValid = sewaValid && namaValid && tanggalsewaValid && jamsewaValid && durasihariValid if (isFormValid) { $w('#button36').enable() } else { $w('#button36').disable() }} /////////////////////// export function button36_click1(event) { let toInsert = { "mobil": $w("#text122").text,
"idMobil": $w("#text123").text, "subRental": $w("#text124").text, "lokasiRental" : $w("#text125").text, }; wixData.insert("HasilFormulir", toInsert) .then( (results) => { let item = results; //see item below } ) .catch( (err) => { let errorMsg = err; } );}