Jump to content

Condition Dropdown Values


Recommended Posts

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

Link to comment
Share on other sites

 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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...