How to do Correlation for below scenario - correlation

I need the value beside "selected" in below for correlation
Code:
id="ctl00_ContentPlaceHolder1_GVMembers_ctl04_ddlRelation" class="ddl" style="width:100px;">
<option selected="selected" value="6">Husband</option>
<option value="1">Wife</option>
<option value="2">Father</option>
<option value="3">Brother</option>
<option value="4">Sister</option>
<option value="5">Daughter</option>
<option value="7">Spouse</option>
<option value="8">Son</option>
<option value="9">Mother</option>
<option value="10">Mother In Law</option>
<option value="11">Brother In Law</option>
<option value="12">Father In Law</option>
<option value="13">Others</option>
but cannot use regex because client is using LR9.1
also when save param is to capture ""
the ord is changing for every vuser.
Please help me with this.
And also the Selected values will also me changing from 1 to 13.
Thank You

You can use <option selected="selected" as LeftBounddary and </option> as Right Boundary,which will fetch value="6">Husband
And to get the value(i.e Husband) you have to do some string manipulation
Eg:- strtok function using > as delimiter

You can use a regular expression:
web_reg_save_param_regexp(
"ParamName=SelectedOption",
"RegExp=selected\" value=\"\\d+\">(.*?)<\/option>",
LAST);
That will only grab the 'husband' part, if you want the option number you can use:
web_reg_save_param_regexp(
"ParamName=SelectedOption",
"RegExp=selected\" value=\"(\\d+)\">.*?<\/option>",
LAST);

Related

Regular Expression for Extracting values from dropdown in Jmeter

To start with - I am new to writing regular expressions.
I have two dropdowns as FromCity and ToCity which ate HTML options (as dropdowns). However both are having same left right boundary due to which not able to extract the specific values of a drop down at runtime.
e.g.
FROM CITY DROPDOWN
<select name="fromPort" class="form-inline">
<option value="Paris">Paris</option>
<option value="Philadelphia">Philadelphia</option>
<option value="Boston">Boston</option>
<option value="Portland">Portland</option>
<option value="San Diego">San Diego</option>
<option value="Mexico City">Mexico City</option>
<option value="São Paolo">São Paolo</option>
</select>
TO CITY DROPDOWN
<select name="toPort" class="form-inline">
<option value="Buenos Aires">Buenos Aires</option>
<option value="Rome">Rome</option>
<option value="London">London</option>
<option value="Berlin">Berlin</option>
<option value="New York">New York</option>
<option value="Dublin">Dublin</option>
<option value="Cairo">Cairo</option>
</select>
I can fetch the city names with - <option value="(.*?)"> but not able to distinguish which value is for which dropdown.
Is there a better way to handle this using regular expression ?
Using regular expressions for parsing HTML is not the best option, I would rather suggest using CSS Selector Extractor instead
This way you will be able to get "from" city names as select[name=fromPort] option and "to" city names as select[name=toPort] option
Demo:
More information:
CSS Selectors Reference
How to Use the CSS/JQuery Extractor in JMeter

Persist javascript changes alongside Laravel 9 and Livewire 2

I have two select option fields--one with the ID of determined and the other vehicle_type. Determined has 4 options--2 of which should disable the options in the vehicle_type select field. In the console, I see the disabled attribute being added, but because of Livewire, is immediately removed. Any way of persisting my changes and force Livewire not to send updates to the server?
<select wire:model="determined" id="determined"
name="determined">
<option selected value>Please Select</option>
<option value="0">Published HP Figure (DIN)</option>
<option value="1">Measured with Dynojet+Dyno</option>
<option value="2">Measured with Mustang Dyno</option>
<option value="3">Measured with Engine Dynamometer Cell</option>
</select>
<select wire:model="vehicle_type" id="vehicle_type"
name="vehicle_type">
<option selected value>Please Select</option>
<option value="0">Stick shift and 2WD vehicle</option>
<option value="1">Automatic or 4WD Drive</option>
</select>
#push('scripts')
$(document).ready(function() {
$('#determined').on("change", function() {
const dis = $(this).val() == 0 || $(this).val() == 3;
$("#vehicle_type option").prop("disabled",dis)
});
});
#endpush
Use .defer on the wire:model to prevent Livewire from making an ajax request immediately and re-render the component.
<select wire:model.defer="determined" id="determined" name="determined">
<option selected value>Please Select</option>
<option value="0">Published HP Figure (DIN)</option>
<option value="1">Measured with Dynojet+Dyno</option>
<option value="2">Measured with Mustang Dyno</option>
<option value="3">Measured with Engine Dynamometer Cell</option>
</select>

october cms ajax and options values

Is it possible to send value from options on example like this where x need to be value from option. This select im using on partial and ajax works with manualy added value as x. THX!
<select data-request-data = "id: x " class="form-control custom-select" data-request="onChangeValue">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
Just give your select a name, an unique name.
name="some_unique_name"
<select name="my_super_special_name_for_select" class="form-control custom-select" data-request="onChangeValue">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
Then when you change the value the value of the field is sent along in post
The result of:
public function onChangeValue()
{
traceLog(post());
}
In the log you will see then a result corresponding to
["my_super_special_name_for_select" => 5 ]
So you can fetch it with post('my_super_special_name_for_select') or whatever name you have given the select element to get the value.
public function onChangeValue()
{
$id = post('my_super_special_name_for_select');
}
Yes you can send value from select. But for this you will need to put it inside a form and then call data request on it. Value will be sent as part of post(). It can't be sent dynamically like the way you are using. if you can elaborate your external conditions more I can suggest other solutions too.

Select input ,selected Text codeigniter

I have form with input select in the aplication/view codeigniter
and the form is submited by codeigniter, no ajax.
<select name="sel_options">
<option value="1">hi</option>
<option value="2" selected>bye</option>
</select>
in my aplication/controller
$this->input->post("sel_options");
result:
2
but i need the text ("bye");
When you post a value, it's going to use the value from the input. So in your case:
<select name="sel_options">
<option value="1">hi</option>
<option value="<!-- I'm Submitting this value -->" selected>bye</option>
</select>
The value for the second option is 2 (<option value="2" ... />) if you wanted to pull in the value from the html ('bye'), you'd have to set the value to be bye.
<option value="bye" selected>bye</option>

Html select dropdown list - how to choose the selected value from server code

I have a select list say of states in the country, which i have in a helper to include easily in any form. (removing most options to make it brief).
I have the value of the current selection stored in the database say "CA". How would i set selected="true" to option CA before rendering the list to the user?
#helper StateSelect(string name = "State")
{
<select name="#name" id="#name" class="required">
<option value="">-- Select -- </option>
<option value="AK">Alaska</option>
<option value="AL">Alabama</option>
<option value="AR">Arkansas</option>
<option value="AZ">Arizona</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="VA">Virginia</option>
<option value="VT">Vermont</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
}
As Darin Dimitrov says, the built-in stuff would be better. However, if you do need to, I think you have a few options:
Add code like this to every line:
<option value="CA" #(name == "CT" ? "selected=selected" : "")> Connecticut</option>
Just re-add the selected item to the top of the list
This keeps the code cleaner, the selected option is just repeated at the top (and selected there), before the entire list

Resources