Page 2 of 2

Re: Fill in internet explorer drop down box in form using com

Posted: 17 Jul 2017, 16:13
by smbs
Well thanx to all your help I have come a long way.
Using the javascript above as a google chrome snippet as suggested by sancarn and creating a loop I am able to fill in almost automatically multiple forms using Chrome which was my original request so many thanx to all.
Sancarn
Finally, if you want a list of options you can use this JavaScript function:
Finally, if you want a list of options you can use this JavaScript function:

Code: Select all

function getOptions(element){
	var options=[]
	if(element.tagName!="SELECT") return []
	o = element.options
	for(i in k){if(typeof(k[i])=="object") options.push(k[i].value)}
	return options
}
Used like

Code: Select all

 getOptions(document.querySelector('#address-main > div.sa-form > div:nth-child(4) > div > select'))
Pls could you explain in greater detail how to use this function as I want to try and understand how you obtained the list of options you posted to me.
Many thanx

Re: Fill in internet explorer drop down box in form using com

Posted: 18 Jul 2017, 07:00
by sancarn
Let's take this as an example.

On the combobox/dropdown element, on the right hand side of the page - right click and click 'inspect'

You should see the Developer tools pops up and a <select>...</select> is displayed. Right click on this element and choose Copy>Copy selector (ps. this is a feature specific to google chrome)

Now in the javascript console type: getOptions(document.querySelector('<PASTE CLIPBOARD HERE>'))

Run this command and it will return a list of options.

The returned value will be an array: ["volvo", "saab", "opel", "audi"]

P.S.

Make sure the getOptionsfunction is defined first!

Edit:

Apparently there was a mistake in my code. Here is the refined version:

Code: Select all

function getOptions(element){
	var options=[]
	if(element.tagName!="SELECT") return []
	var o = element.options
	for(i in o){if(typeof(o[i])=="object") options.push(o[i].value)}
	return options
}

Re: Fill in internet explorer drop down box in form using com

Posted: 18 Jul 2017, 13:55
by smbs
sancarn
Many thanx after me being "spoon feed" I really managed to sort things. The "copy selector" was the step I really never understood!
Many many thanx for your patience and help. :D

Re: Fill in internet explorer drop down box in form using com

Posted: 19 Jul 2017, 12:56
by sancarn
smbs wrote:sancarn
Many thanx after me being "spoon feed" I really managed to sort things. The "copy selector" was the step I really never understood!
Many many thanx for your patience and help. :D
I did wonder whether that was the case, so decided that a step by step guide would be best :)

You're welcome! Anytime! :D

Re: Fill in internet explorer drop down box in form using com

Posted: 19 Jul 2017, 15:12
by tank
onchange event?