Tags down


How to select a specific option based on multiple attribute?

By : Dmitry Chumak
Date : October 14 2020, 08:10 PM
wish helps you You can specify both criteria as .find('option[value=3][id-criteria=2]').
code :
   .prop('selected', true);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<select class="required form-control parameter-criteria" selectpicker="" data-id="2" tabindex="-98">
    <optgroup label="criterio 2">
        <option value="1" data-content="<span class=&quot;badge-min filter d-inline-flex&quot; style=&quot;background-color:#ff0000;&quot;> </span>CRITERIO 1 [0 - 50] - CRITERIO 2" id-criteria="2">CRITERIO 1
       <option value="2" data-content="<span class=&quot;badge-min filter d-inline-flex&quot; style=&quot;background-color:#ffb700;&quot;> </span>CRITERIO 2 [51 - 60] - CRITERIO 2" id-criteria="2">CRITERIO 2
       <option value="3" data-content="<span class=&quot;badge-min filter d-inline-flex&quot; style=&quot;background-color:#66ff00;&quot;> </span>CRITERIO 3 [61 - 100] - CRITERIO 2" id-criteria="2">CRITERIO 3

Share : facebook icon twitter icon

How select specific custom attribute in an select option field?

By : Erica0721
Date : March 29 2020, 07:55 AM
this one helps. You can use attribute selector to get the option with attribute test with specific value.
Live Demo
code :
$('#dropdown option[test=C]').prop('selected', true);

get select menu to dynamically show specific select option based of MySQL SELECT result

By : Reigam
Date : March 29 2020, 07:55 AM
it helps some times I have a php page where users type in a specific id number in a text field and click a "SEARCH" button. Upon clicking "SEARCH", a php script runs to connect to a MySQL Database table "xxx"and grab the row id that matches the id number entered by the user. The SELECT statement grabs the database values: "productionstage" and "floornotes" for the identified row. , You need to make few changes in your code, such as:
code :

    <fieldset id="doneButtonField">
        <input type="button" name="doneButton" id="doneButton" value="DONE">
    var sgnumber = $('#sgnumber').val();
    $.ajax ({
        method: 'POST',
        url: "workordermovementGET.php",
        data: {sgNumber: sgnumber},
        dataType: 'json',
        success: function( data ){
                $("select#stageSelect option").filter(function() {
                    return $(this).val() == data.productionstage; 
                }).prop('selected', true);

    if (isset($_POST['sgNumber'])) {
        $sgNumber = $_POST['sgNumber'];

        //connect  to the database 
        $conn = new mysqli($servername, $username, $password, $dbname);

        // Check connection
        if(mysqli_connect_errno() ) {
            printf('Could not connect: ' . mysqli_connect_error());


        if(! $conn->select_db($dbname) ) {
            echo 'Could not select database. '.'<BR>';

        $sql= "SELECT productionstage, floornotes FROM invoices WHERE id = ?";
        $stmt = $conn->prepare($sql);
        $stmt->bind_param('i', $sgNumber);

        if ($stmt->num_rows == 1) {
            $stmt->bind_result($productionstage, $floornotes);

            echo json_encode(array('status' => true, 'productionstage' => $productionstage, 'floornotes' => $floornotes));
        } else {
            echo json_encode(array('status' => false));

Select a specific option based on the option group in selenium

By : Lucia Leni Hardiyant
Date : March 29 2020, 07:55 AM
wish helps you hopefully this will not be an duplicate. I searched in web but could not find the exact solution for what i need. I have a dropdown with option groups. I need to select a value based on the input option group "Primary Borrower" or "Co-Borrower" from the dropdown and proceed. Could you please help me on how to do that. , XPaths are the solution.
code :
WebDriver.findElement(By.xpath("//select[@id='selected-borrower']/optgroup[@label='Primary Borrower']/option")).click();

Disable/delete select option based on another select option data attribute value

By : user1758640
Date : March 29 2020, 07:55 AM
I wish this helpful for you I want to show options from #cities2 if #cities option value is matching #cities2 data-attribute value.
code :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select name="cities" id="cities">
    <option value="Los Angeles">Los Angeles</option>
    <option value="Miami">Miami</option>
    <option value="Las Vegas">Las Vegas</option>
    <option value="Chicago">Chicago</option>

<select name="cities2" id="cities2">
    <option data-cities="Los Angeles">Los Angeles</option>
    <option data-cities="Miami">Miami</option>
    <option data-cities="Las Vegas">Las Vegas</option>
    <option data-cities="Chicago">Chicago</option>

    var option = $(this).val();
    console.log("Selected first: " + option);
    if ($(this).val() == "Miami" && option == "Miami") {
      console.log("This is Miami");
      $("#cities2 option").prop('disabled',true);           
      $("#cities2 option[data-cities='Miami']").prop('disabled', false);
      $("#cities2 option[data-cities='Miami']").prop('selected',true); 
    } else {
      console.log("Not Miami");
      $("#cities2 option").prop('disabled', false);

How to get Selected option Data Attribute in multiple select option

By : mjhixson
Date : March 29 2020, 07:55 AM
seems to work fine User select more than one value. How i can get every selected data attribute value. , You get an array of selected options.
code :
$('#EMaddMoreEmployee').on('change', function() {
    var selected = $(this).find('option:selected', this);
    var results = [];

    selected.each(function() {

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="EMaddMoreEmployee" name="EMaddMoreEmployee[]" multiple="" tabindex="-1" class="select2-hidden-accessible" aria-hidden="true">
  <option value="3" data-available_text="Prashant Kumar is unable to work today.">Prashant Kumar</option>
  <option value="4" selected="" data-available_text="Anand Kumar has not given availability for this day.">Anand Kumar</option>
  <option value="7" data-available_text="Manoj Kumar has not given availability for this day.">Manoj Kumar</option>
  <option value="8" data-available_text="Delip Kumar is available to work all day.">Delip Kumar</option>
  <option value="9" data-available_text="Purendar Kumar has not given availability for this day.">Purendar Kumar</option>
  <option value="10" data-available_text="Subhas Kumar has not given availability for this day.">Subhas Kumar</option>
  <option value="11" data-available_text="Hera Dheware has not given availability for this day.">Hera Dheware</option>
  <option value="12" data-available_text="Puspa Di has not given availability for this day.">Puspa Di</option>
Related Posts Related Posts :
  • How to get prefix name from html tag
  • javascript - Simulate a click event (tap with finger) on a button in iOS
  • How to get the value of checkboxes in a kendo grid
  • Uncaught TypeError: Object(...) is not a function at eval (global-styles.js)
  • Generate divs on scroll bottom
  • App deployed to Cloud Foundry fails to start
  • Show label and percentage in Google pie chart
  • Warn user before leaving web page if changes haven't been saved
  • Objects are not valid as a React child getting error when adding div?
  • why is callback not working in nodejs with mysql?
  • D3 v4 date ticks never display last item
  • How to assign a variable which function takes as a parameter
  • Javascript how hidden div onclick of phrase
  • Can I set state inside a useEffect hook
  • How can I draw a line to the highest datapoint in chart js?
  • Make <a> link activate expand text button
  • Django: fastest way to update the data that was once sent from template to view
  • JavaScript Scope of Vaadin's "AbstractJavaScriptComponent"
  • Firestore cloud functions summing subcollections values
  • d3.js in vue component - How to hook mouse events to elements?
  • Can't add href and class to list item through javascript
  • Jest - checking local storage is called in an async function that is being mocked
  • How do I print only the selection from my list group item?
  • Using take(1) with an Observable<boolean>?
  • Multi Step Form Javascript
  • Javascript checking if username already exists(duplicate)
  • Download text file from an external URL
  • get jquery post data in node.js
  • How to cache random results using Ember data?
  • Credentials for Microsoft.Maps.TileSource callback
  • Expand particles.js to background
  • how to receive updated props in react js?
  • How do I run my code when device is connected by usb?
  • How to make javascript function can use after dot
  • Progress bar with Tooltip message should be displayed always
  • Javascript interactive card being glitchy
  • Blank data for certain hours - hence missing in my array. Is there a way to fill in the missing hours?
  • Width changing when switching from static positioning, to fixed positioning
  • Javascript form validation(oninput)
  • Stock getJSON data in a global var but later says its undefined
  • RxJS throwError event not directed to handler?
  • Non-greedy capturing parenthesis
  • Refer to class inside of static method without using its name
  • Filter array property of object without mutating the object itself
  • How to create a local module in TypeScript
  • Django - Get "total" between two elements in HTML in real-time using a script
  • How can I filter and exclude 1 item type in React?
  • Output for javascript program is 'undefined' when trying to run in command line
  • Javascript onclick if iframe exists, remove it and create new iframe?
  • Merge objects with with missing key
  • Cannot find module 'jsonwebtoken' Node.js
  • Creating a cumulative objects using javascript
  • How to write regexp to get a paramater from URL
  • Instead of getting pushed to array I get error
  • DOM Dynamic Table calculation
  • How to execute JavaScript from file
  • jQuery last child val() undefined
  • React filter and then swap array elements
  • How do I return a not found in filter function in jQuery?
  • inner json array cannot be accessed in javascript, but can console log the complete json
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org