HTML5 Data Bindings Support Product Page

Answered

Select selected

Asked 15 Oct 2015 03:26:31
2
have this question
15 Oct 2015 03:26:31 Steven Irwin posted:
Hi,
I have a select which is populated through an option repeat.
I want to select to show the option selected that equals a url parameter.
How can I do that with html5 data bindings?

Promoted Answers

Replied 15 Oct 2015 08:01:25
Hello Steven,

You need to Bind an URL parameter to the select value. To define a URL param in Data Bindings Floater you need to select the URL folder and click on the + icon above . Then enter the name of the URL parameter you like to watch for.
prntscr.com/8rhp1o
Then select the select element you like to be affected from the URL parameter. Then in Data Bindings floater extend the $URL folder and select the URL parameter you have previously defined. Then in the footer of the Data Bindings Floater make sure select.data.value is selected and press Bind button.
prntscr.com/8rhq2s
You are all set.

Replies

Replied 15 Oct 2015 08:01:25
15 Oct 2015 08:01:25 Miroslav Zografski replied:
Hello Steven,

You need to Bind an URL parameter to the select value. To define a URL param in Data Bindings Floater you need to select the URL folder and click on the + icon above . Then enter the name of the URL parameter you like to watch for.
prntscr.com/8rhp1o
Then select the select element you like to be affected from the URL parameter. Then in Data Bindings floater extend the $URL folder and select the URL parameter you have previously defined. Then in the footer of the Data Bindings Floater make sure select.data.value is selected and press Bind button.
prntscr.com/8rhq2s
You are all set.
Replied 15 Oct 2015 08:37:35
15 Oct 2015 08:37:35 Steven Irwin replied:
Thanks Miroslav,

Worked perfectly!

I always struggle with selects and checkboxes for some reason.

Cheers and thanks for the quick response!

Steve
Replied 11 Feb 2016 16:26:29
11 Feb 2016 16:26:29 Hans Haverlach replied:
I don't get it. This method above, gives me a dropdown with all titles having the same value (url value).

For me the question remains:
How can I have a dynamic select with all items in it, but one item selected on base of given value (this value can come from a URL parameter, but I also like to know if I can get an value from a given dataset?

I hope someone will response to this!

Thank you.

Hans
Replied 12 Feb 2016 08:28:54
12 Feb 2016 08:28:54 Miroslav Zografski replied:
Hello Hans,

QuoteI don't get it. This method above, gives me a dropdown with all titles having the same value (url value).


Then you have set different binding.
First of all you need to have the Select already populated - either dynamically from data set or statically.
Then you must make sure that the option elements values are of the same format as the value passed in as URL parameter - in example:
A select with categories

<select id="catProd" name="catProd" data-binding-value="{{$URL.catID}}" data-binding-id="repeat1" data-binding-repeat-children="{{categories.data}}">
      <option value="{{catID}}">{{catName}}</option>
</select>


In the above example the select is populated from categories data set and the selected option is set by using the $URL.catID as value for the select via the method described above.

Regards.

Reply to this topic