Jump to content

Selecting a Combo/Dropdown with Javascript


user52
 Share

Recommended Posts

I'm trying to set a new value to the combo/dropdown AND

get the form/page to register the event

post-14453-1165053409_thumb.jpg

here's how the combo/drop is created in the html

<script>
var win = window.isOLC ? window : parent.makeDropdown ? parent : window; 
var dd = win.makeDropdown('status', 184, ['', '', 'Not Started', '1', 'In Progress', '2', 'Waiting for Customer', '6', 'Escalated', '3', 'Closed', '5'], 3, '6', 'Waiting for Customer', "window.ischanged = true; Syncstatus(true);", null, 200,document,67584);
</script>

this is the code i've tried

$oInput = _IEGetObjByName ($netsuite_oIE, "inpt_status")
$input_val = _IEFormElementGetValue($oInput)

MsgBox(0,"Combo's Value",$input_val) ;this works

;this set's the value correctly, but when the form is submitted the change is not recorded
_IEFormElementSetValue($oInput, "Closed", 1)

(no SEND("") please)

thanks for the help

Link to comment
Share on other sites

It looks like you have dynamically created HTML on that page. Please use _IEBodyReadHTML to examine the source - the script will not help you.

You will then need _IEFormElementOptionselect instead of _IEFormElementSetValue

Finally, you will need the T2. 0-6 or higher version of IE.au3 (see my sig) to avoid a bug in _IEFormElementOptionselect that will always select the blank entry if you use byText mode.

Dale

Edit: mistakenly referenced _IEFormElementGetValue instead of _IEFormElementSetValue

Edited by DaleHohm

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

It looks like you have dynamically created HTML on that page. Please use _IEBodyReadHTML to examine the source - the script will not help you.

You will then need _IEFormElementOptionselect instead of _IEFormElementSetValue

-they're being tricky. It is in fact an input (not a combo) that i'm am selecting from. they use a down arrow post-14453-1178047499_thumb.gif (ddarrow.gif) as the input's background image.

-notice in the code below that the INPUT title="Closed" is using the arrow down background image and it has the class='dropdownInput'

-how do i get the page to register a change if i set the input to a new value? thanks

<span id='status_fs' class='nldropdown' style="white-space: nowrap;">
    &lt;script>
    var win = window.isOLC ? window : parent.makeDropdown ? parent : window; 
    var dd = win.makeDropdown('status', 184, ['', '', 'Not Started', '1', 'In Progress', '2', 'Waiting for Customer', '6', 'Escalated', '3', 'Closed', '5'], 8, '5', 'Closed', "window.ischanged = true; Syncstatus(true);", null, 200,document,67584);
    dd.setMandatoryBackgroundColor('FFFFE5');
    dd.setRequired(true);
    </script>
    
###HERE!
    <input title="Closed" style="background-image: url(/images/forms/ddarrow.gif); width: 200px; background-color: rgb(255, 255, 229);" name="inpt_status" id="inpt_status5" value="Closed" class="dropdownInput" onkeydown="getDropdown(this).handleKeydown(event);" onkeypress="getDropdown(this).handleKeypress(event);" onfocus="this.select()" contenteditable="false" autocomplete="off" type="text">
    <input name="status" id="hddn_status5" class="nldropdown" value="5" onchange="window.ischanged = true; Syncstatus(true);" type="hidden">
    <input id="indx_status5" value="8" type="hidden">
</span>

.dropdownInput{
    background-color: white; color: black;
    font-size: 8pt;
    padding-left: 1;
    border-style: solid;
    border-width: 1;
    border-color: #999999;
    background-image: url(/images/forms/ddarrow.gif);
    background-repeat: no-repeat;
    background-position: center right;
    cursor: default
}

edit: image locally hosted

Edited by user52
Link to comment
Share on other sites

  • 4 months later...

SOLVED!!

the page uses inputs as combo dropdowns. it turns out there were hidden inputs that javascript was changing when you selected an option from the dropdown.

SOLUTION:

simply change the value of the visible AND hidden inputs using _IEFormElementSetValue() and voila! it works!!

the inputs:

Index,Id,Name,Type,Value,Label,Size,Maximum Length,State

23,inpt_status5,inpt_status,text,In Progress,,,,

24,hddn_status5,status,hidden,2,,,,

25,indx_status5,hidden,2,,,,,

Edited by user52
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...