Link to home
Start Free TrialLog in
Avatar of Kanwaljit Singh Dhunna
Kanwaljit Singh DhunnaFlag for India

asked on

VBA Macro not working properly

Hi Experts,
Using the macro in attached Excel File, I am able to fill the data in the online web form. But strangely enough one of the filled value ("Mode of Payment") is not being accepted by the web site. But if I select a different value from the drop down and again select the Original value, then the same is being accepted.

Is there any issue with the VBA Code ? Please rectify if there is any error.
I have attached one short video of the error xzRSaszPgV.mp4 
Also the excel file is attached.Challan Fill.xlsm
Avatar of HainKurt
HainKurt
Flag of Canada image

somehow, can you run this on page load

setBankDetails(1);

see demo

https://jsfiddle.net/HainKurt/2vnL3zxe/

$('#NetBank_Name_c option:eq(4)').attr('selected', 'selected');

Open in new window

if I change selected item, change event is not triggered...
but if I manually call change event, it fires

$('#NetBank_Name_c option:eq(4)').attr('selected', 'selected');
$("#NetBank_Name_c").change();

Open in new window

so, your problem is not VBA
but the onchange events are not triggered if you change them programmatically...
you have to call change event of those select/radio buttons...
Avatar of Kanwaljit Singh Dhunna

ASKER

Thanks for the reply !
I can understand what you are saying, but not sure I am technically capable enough to cull out or incorporate the same in my code to derive the solution.
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a Lot Sir !
I wonder why I was facing the same issue for the last 3 years.
All I knew was that manually selecting the bank name resolved the issue, but don't know the reason and off course, not the solution. Can you elaborate the reason a bit ?
and what that magic line did ?
there are lots of codes behind the scene
triggered when you select radio or select box, onChange events
but when you populate it programmatically, they dont run
and page thinks you never selected anything...

so, when you set X, app does not know X is selected
but when you select Y then X, that code runs...
I got a bit of what you said......
But my problem is solved.

Thanks a Lot Sir !
Wonderful !
and what that magic line did ?

called the change event of select box, as if, it is selected with mouse...
Okay ! Got it !
Thanks a Lot Sir ! That was swift and precise !