bagus
June 23, 2020, 6:54am
1
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();
bagus
June 23, 2020, 11:32am
3
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 _click 1 (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;
} );}
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
Hello Gund Rock,
i am not really sure if i understand your problem at all, because i can not see your complete project.
But if you want to start 2x functions by clicking just one button, you can make it like this…
exportfunctionbutton36_click(event) {
start_FUNCTION1()
start_FUNCTION2()
}
function start_FUNCTION1 () { ....your CODE here for function1...}
function start_FUNCTION2 () { ....your CODE here for function2 ....}
Take a look what Ahmad writes in his post, it is really better to use the dataset (i also already mentioned this option in my first post).
Ahmed gave you now a detailed description what and how to do.
“And by the way, why do you need the inputType ?? I think what you want is the value of the input field.”
Yes i think this is what Gund Rock wanted to do.
bagus
June 23, 2020, 2:24pm
6
Sorry this way is not possible!
Hi, you can’t submit data on a read-only
bagus
June 29, 2020, 6:08am
11
@ahmadnasriya @russian-dima
Thanks u very much for all of you people, it’s work perfect. yeargh!
bagus
July 3, 2020, 3:45am
13
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,
} )} );}
Some work for Ahmad , good night corvid-forum.
This question is already answered, for further questions please open a new thread and we’ll be happy to help.