Michelle Posted April 22, 2016 Report Share Posted April 22, 2016 Hi all. I am stuck with one question. How to select automatically value from dropdown based on value of other field. I have two date fields, and i want if 1>2, then dropdown= "Ready for shipping", if 1<2 , then dropdown= "Delayed", if 1=2 , the dropdown= "Delivered" I appreciate any help. Thanks Quote Link to comment Share on other sites More sharing options...
Aurora Posted April 22, 2016 Report Share Posted April 22, 2016 Hi Michelle ! I think I have some similar code. In my case there are 3 values - Done is # 1 in dropdown , which equals [0] in the script, Pending-#2 in dropdown and equals [1] in script, and Canceled- #3 in dropdown, [2] in script. Here is the code: <SCRIPT LANGUAGE="JavaScript"> function calculate() { var dropdown =(document.getElementsByName("EditRecordYour_Field1")[0]); var date1 = new Date(document.getElementById("EditRecordDate_Field").value); var date2 =new Date(document.getElementById("EditRecordDate_Field2").value); if (date1>date2) { dropdown.options[2].selected=true; } if (date1<date2) { dropdown.options[0].selected=true; } if (date1.getTime()===date2.getTime()) { dropdown.options[1].selected=true; } } document.getElementById("EditRecordDate_Field2").onchange=calculate; </SCRIPT> The script works when you change second Date field. Good luck, Aurora MayMusic 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.