insert a text box value into a input field

insert a text box value into a input field ,


the test and the input field are on the same page.

1 Like

Hi Amit,

If the elements are on the same page, then you would want something like this.
$w(“#input1”).value = $w(“#text1”).text;

I hope this helps.

Yisrael

still not showing up text value is on different database and the input field is connected to different database

Hi,

Make sure to add the line inside the onReady event for your dataset:

export function dataset1_ready() {
    $w('#input1').value = $w('#text1').text;
}

They are showing up on the input field now but when I submit the data except that one others get submitted

Please post the URL of your site. Only authorized Wix personnel can get access to your site in the editor.

sure.

Hi Amit,

On what page are you having the problem?

Tripoli shop pages- Tripoli item

I don’t see the field on the page. Where is it? It doesn’t appear to be in the location as indicated in the image below:


What is the field name?

the field name is productid in Cart database
there is only one item with product id currently this one


when i click purchase it inserts the value into the input


the price, title and product id and rest will be filled by the user


when i submit it only the one’s i filled gets submitted

and this is the code

You have the value of #button36 connected to the TRIPOLI dataset, which is connected to the TRIPOLI collection. There is only one record in that collection that has a productid which is why you are probably not getting a value.

No i am getting the value in the input box it’s just that it is not getting submitted to the cart dataset other inputs which i am typing are getting submitted

when i click purchase button i get the productid value in the input box but when i sumbit it it’s not getting submitted, others are

found a workaround
now it works.

let productid = $w("#button36").label;
$w("#dataset4").setFieldValue("productid", productid);

Use insert() to insert your data in a collection instead of selecting submit on the button’s properties.

Hey Amit,

Good job!

You ending up finding the same workaround that I found for another case. It seems that the common case is that if a field is changed programmatically (that is, not by the user selecting or typing something) then the corresponding field doesn’t get changed in the dataset. I’ve reported this to QA.

Yisrael

Hey Manny,

Your solution is probably a more direct method, although more “hands-on”. It eliminates the need for that wonky workaround (which in any case shouldn’t be needed).

Yisrael

Yeah took me a while to figure that out.

Hi Yisrael,
I am having a similar issue where my fields that have data inserted by code are not being populated in the dataset but any field where I type into it does. I was wondering if there were any updates from QA when you reported it? I will try the workaround that you guys posted but I was hoping that if the fields are connected properly to the dataset that all of the data would be refelected in the dataset no matter how the field was populated.

Thanks,
Jacob