read-only textbox

I did some calculation and displayed in a read-only textbox. When user click submit, all inputs will be transferred to collection. but the value in read-only textbox appear null in collection. why is that?

Hello Siti,

Make sure when displaying it in the read only textbox you set the .value not the .text of the element.
However, you can submit using code instead of on click as follows:

let toInsert = {
      “feildName” : #w(‘#inputValue’).value();   
};
wixData.insert("myCollection", toInsert)
.then( (results) => {
let item = results; //see item below
} )
.catch( (err) => {
let errorMsg = err;
} );

Check this link for further information: http://www.wix.com/code/reference/wix-data.html#insert

Massa

1 Like

I have tried the coding but it says that .value() is a property instead?

export function button3_click(event, $w) {
//Add your code for this event here:
let toInsert = {
“total” : $w(“#totalPrice”).value();
};

wixData.insert("jrmns", toInsert) 

.then( (results) => { 
let item = results; //see item below 
} ) 

.catch( (err) => { 
let errorMsg = err; 
} ); 

}

Hello Siti,
what’s the $w(" #totalPrice "). type?
if it’s a text box, you have to use .text, else if it’s user input you have to use .value ()

export function 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)
.then( (results) => {
let item = results; //see item below
} )
. catch ( (err) => {
let errorMsg = err;
} );}

no information failed, but I checked in the database there was no input.
help me please :frowning:

This is an old post and should be closed, please open a new thread and leave a link to this post in your thread.

ok