Jump to content

Selecting option value based on the "value"


Go to solution Solved by jasontj,

Recommended Posts

Hi.  I am trying to select the value from a drop down "select" list from this site:

https://www.dallascounty.org/criminalBackgroundSearch/search.jsp

I want to change the DOB Month and DOB Day based on the "values".  So, 01, 02, etc from these lists.  

 

<select name="dobMonth" size="1" class="form-select form-select-lg">
                                <option value="">&nbsp; </option>
                                <option value="01">January</option>
                                <option value="02">February</option>
                                <option value="03">March</option>
                                <option value="04">April</option>
                                <option value="05">May</option>
                                <option value="06">June</option>
                                <option value="07">July</option>
                                <option value="08">August</option>
                                <option value="09">September</option>
                                <option value="10">October</option>
                                <option value="11">November</option>
                                <option value="12">December</option>
                            </select>
 

Below is the only code that I have found that works.  Sure seems overly complicated.  I'd love to have a more efficient solution for this. 

_WD_ExecuteScript($sSession, "var element = document.evaluate('/html/body/div/form[1]/div[10]/div/div[2]/select', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; element.value = '" & $sCellValueMonth & "'; element.dispatchEvent(new Event('change'));")

Thanks in advance for any help on this.

Jason

Link to comment
Share on other sites

    ; line below works.  just need to subtract 1 from the month value.  Should work the same for Day.
_WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "//select[@name='dobMonth']//option[03]")

I did, but this will only for when the values in the list are numbered, like day of Month.  I've got another page where the states need to be selected, "TX", "UT", etc.  So I need this to work based on a value, not on a position.  I must be missing something simple on this.

 

 

Link to comment
Share on other sites

  • Solution

Got it.  Thanks for the push in the right direction @Danp2

$sCellValueMonth = "05" ;  this will set it to "May"

_WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "//select[@name='dobMonth']/option[@value='" & $sCellValueMonth & "']")

 

Link to comment
Share on other sites

  • Developers
10 minutes ago, mikos65 said:

I'm trying and I can't do anything :(

that is a silly answer! Show what you are trying is the simple question!

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...