How to encode option value into url? - url

I have a page (https://bpraktar.hu/Karcher-WD-2-Premium-Basic-EU-I-Nedves-szaraz-pors) where I'd like to select the value of the dropdown option automatically without touching the site. How can I encode this selection right into the URL, without changing the site content so that when the user visits the page the selection is selected via URL?
The select with the options:
<select name="egyeb_list1" id="egyeb_list1_556745" class="page_artdet_other_select text_normal">
<option value="Kattints az 5 év jótállásért!" selected="selected">Kattints az 5 év jótállásért!</option>
<option value="5 évre Kiterjesztett Jótállással">5 évre Kiterjesztett Jótállással (+5 716 Ft)</option>
</select>
With the URL I'd like to select the second option.

Related

How to select and add a new item in select2

I am pulling my hair off trying to do a very simple thing with select 2. When I edit a record of table1, I have a simple select dropdown with a list of items built from a field of table1 (with distinct). Sometimes I need to add a new item. So I thought that the example to create and add a new item would work but it does not. When I type the new item in the open box on top of the dropdown, I got "No result found"... ok but how do I force this new item to be selected and recorded in the database (and obviously available for later use)?
I am not really good in JS, so I presume I am doing something wrong or something is missing... please help.
<select class="selectAdd-who" name="who">
<option value="item1">item1</option>
<option value="item2" selected>item2</option>
<option value="item3">item3</option>
</select>
<script>
$(document).ready(function() {
$('.selectAdd-who').select2();
// Set the value, creating a new option if necessary
if ($('.selectAdd-who').find("option[value='" + data.id + "']").length) {
$('.selectAdd-who').val(data.id).trigger('change');
} else {
// Create a DOM Option and pre-select by default
var newOption = new Option(data.text, data.id, true, true);
// Append it to the select
$('.selectAdd-who').append(newOption).trigger('change');
}
});
</script>

How to select option from datalist in Cypress

I have a datalist with some options and I want to select the first one using Cypress. How do I do that?
I need to click on the option, simply typing in the value is not what I want, because when an option is selected, a Javascrip function is called. So it's more like How do I click on a datalist option using Cypress?
cy.get('#foods').first().click({force:true})
Does not work.
Presuming the Ruby datalist is like this
<datalist id="foods">
<% Foods.all.each do |food| %>
<option value="<%= food.name %>"></option>
<% end %>
</datalist>
gives this in the DOM
<datalist id="foods">
<option value="Lamb">
<option value="Beef">
<option value="Fruit">
</datalist>
You can get the first option with
cy.get('#foods') // gets the outer datalist
.find('option') // returns all options inside
.first() // take the first
.click({force:true})
for other option, e.g 3rd
cy.get('#foods') // gets the outer datalist
.find('option') // returns all options inside
.eq(2) // take the third
.click({force:true})
The {force:true} is only required because the list is not opened.
It may be better to open it first and click without force, as a page error can be masked by using {force:true}.
cy.get('#foods') // gets the outer datalist
.invoke('show') // open list
.should('be.visible')
.find('option') // returns all options inside
.first() // take the first
.click()

how to make google sheet updated automatically using importxml

i have the following elements on in some url
<div class="col-sm-10">
<select id="geniee_adserverbundle_zone_masterIabCategory" name="geniee_adserverbundle_zone[masterIabCategory]" class="form-control master-category-tier1"><option value="1" selected="selected">Arts & Entertainment</option><option value="2">Automotive</option><option value="3">Business</option><option value="4">Careers</option><option value="5">Education</option><option value="6">Family & Parenting</option><option value="7">Health & Fitness</option><option value="8">Food & Drink</option><option value="9">Hobbies & Interests</option><option value="10">Home & Garden</option><option value="11">Law, Gov't & Politics</option><option value="12">News</option><option value="13">Personal Finance</option><option value="14">Society</option><option value="15">Science</option><option value="16">Pets</option><option value="17">Sports</option><option value="18">Style & Fashion</option><option value="19">Technology & Computing</option><option value="20">Travel</option><option value="21">Real Estate</option><option value="22">Shopping</option><option value="23">Religion & Spirituality</option><option value="24">Uncategorized</option><option value="25">Adult Content</option><option value="26">Illegal Content</option></select>
</div>
i want to get the selected option from the mentioned combobox above. which is Arts & Entertainment
i tried the following formula, and it's not working
=IMPORTxml(L72,"//select[#id='geniee_adserverbundle_zone_masterIabCategory']//option[#selected='selected']")
please note that L72 is a cell where my friends input the specified url.
what i want to do is, when my friends update the URL, google sheet update its cell automatically.
is there anything wrong with my formula or the page prohibit me from scraping their data ?
update : the page is not public, you have to logged in first to get the access. but my account is currently logged in,and when i open the URL, browser redirect me to specified page which contains the mentioned elements.
IMPORTXML only works on public pages. One alternative is to use the URL Fetch service.

jQuery mobile change select value by script fail (nothing happens)

I'm desperately trying to change the option value in of a select at pageshow and it does nothing.
I don't know how to change it
<select name="sliderAutoConnect" id="sliderAutoConnect" data-role="slider">
<option value="1">Off</option>
<option value="2">On</option>
</select>
and the script :
$("#sliderAutoConnect option[value=2]").attr('selected', 'selected');
$('#sliderAutoConnect').selectmenu('refresh');
You need to refresh the slider widget instead of selectmenu. Try this instead:
$('#sliderAutoConnect').slider('refresh');
Everything else worked for me when i tested it. I just changed that one line.

show text field on select other from drop down :ROR

How I should do this using javascript? I looked other places but every example uses Jquery.
Only on select other textbox should visible.
Assuming that you are on an older version of rails which has prototype as the js library.
in the onchange event of the select list add the javascript function to show the div containing the text box (let's say you show the text box for value 5 of the select list):
<select id="select_item" name="select_item" onchange="display_date_range(this);">
... where 5 is the value of the option that needs to show text box
</select>
function display_date_range(list) {
if(list.options[list.selectedIndex].value == 5) {
$("text_div").show();
}
else {
$("text_div").hide();
}
}
<div id="text_div"><input type="text" value="Hooraaahhh..." /></div>

Resources