Jump to content

IE Select Name issue


 Share

Recommended Posts

Hi there

I'm having some trouble selecting a set value from a drop down list in IE.

Here is the HTML. I wish to select Option 4 (by select I mean click on it so it does something, not just display it).

<select id="numBoards" name="numBoards:int"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option></select></div>

And here is my AutoIT snippet (be kind, I'm new).

$oForm  = _IEFormGetObjByName ($oIE, "newTicket")   
$oSelectCurrentModel = _IEFormElementGetObjByName ($oForm, "numBoards")
$oOptions = $oSelectCurrentModel.options
$oBrdCntr = 0
For $oOption in $oOptions
    $oBrdCntr = $oBrdCntr + 1
Next
MsgBox (0, "AutoIT", "Max Boards available is " & $oOption.value & ". Selecting 4.")
_IEFormElementOptionselect ($oSelectCurrentModel, "4" )

So, this does very well at displaying the "4" selection, but I cannot figure out how to "click" it.

Can someone point me in the correct direction plz?

tia

Link to comment
Share on other sites

name="numBoards:int"

And you have used :

$oSelectCurrentModel = _IEFormElementGetObjByName ($oForm, "numBoards")

Change it to :

$oSelectCurrentModel = _IEFormElementGetObjByName ($oForm, "numBoards:int")
Link to comment
Share on other sites

Also note that _IEFormElementOptionselect fires two events when an option is changed:

$o_object.fireEvent("onchange")
    $o_object.fireEvent("onclick")

If Javascript on your page is looking for another event, you may need to fire it manually.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Also note that _IEFormElementOptionselect fires two events when an option is changed:

$o_object.fireEvent("onchange")
    $o_object.fireEvent("onclick")

If Javascript on your page is looking for another event, you may need to fire it manually.

Dale

OK, I see what you are saying, but I don't know how to work out how the html code even calls the javascript, no matter what is triggering the javascript.

I'm not completely convinced we are on the right path, as, even though the number "four" displays in the dropdown list, it is not highlighted as if it is selected. Is this correct behaviour?

FWIW, here is the javascript for the number of boards control. Perhaps it helps (I don't know Javascript).

$("#numBoards").change(function() {
            var status = getStatus();
            var boardsForSystem = BOARDS_FOR_SYSTEMS[status['selectedSystemName']];
        
            // Find the max weeks for this board number
            var maxWeeksThisBoard = 1
            for (var looky in boardsForSystem) {
                if ( boardsForSystem[looky]['boards'] == status['selectedBoards'] ) {
                    maxWeeksThisBoard = boardsForSystem[looky]['maxWeeks'];
                    break;
                }
            }
                
            // Update 'NUMBER OF WEEKS' control
            setWeeksControl(boardsForSystem, status['selectedWeeks'], maxWeeksThisBoard);
            
            // Disable advanced play if > 1 'Number of Weeks' selected
            setAdvancedPlayVisibility(status['selectedWeeks']);            
        
            // Update the 'TICKET PRICE'
            status = getStatus();
            updatePrice(status['selectedSystemName'], status['selectedBoards'], status['selectedWeeks']);
 
            // Create the 'SELECT YOUR NUMBERS' grid
            generateGrid(getStatus());
                
        }); // End 'NUMBER OF BOARDS' control

Thanks for all the help to date

Clark

Link to comment
Share on other sites

Perhaps you could explain in detail the visual differences and differences in behavior when you make the selection manually and when you run your script.

There is not enough information or code from the webpage here to help you.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Thanks in advance again Dale

Here is a snap of the screen prior to any input.

Posted Image

When the user selects a number of boards other than one, the choose numbers area offers that number of boards.

Here is a snap of the drop down list prior to selection

Posted Image

Now here is a picture of what happens after the user selects "4" boards manually.

Posted Image

As you can see, the number of boards available in Area 2 has now increased to four.

However, as you will see from the next screen, if four is selected via the AutoIT code already posted, four displays in the drop down list, but the number of boards in Area 2 does not change.

Posted Image

I hope that this can help you to work out where the problem is.

regards

Clark

Link to comment
Share on other sites

The Javascript may be replying on focus some how. Try adding this to your code:

$oSelect = _IEGetObjByID($oIE, "numboards")

_IEAction($oSelect, "focus")

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Bingo!

You're a genius.

I put the focus immediately prior to the element select and it worked fine, i.e.

$oSelect = _IEGetObjByID($oIE, "numboards")
_IEAction($oSelect, "focus")
_IEFormElementOptionselect ($oSelectCurrentModel, "4" )

Thanks again for your help. This had me stumped completely.

Clark

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...