Jump to content

java script with conditional blockout


Recommended Posts

This is my deployment code.

Click here to load this Caspio Online Database app.

In this code their is one table and three columns. The jScript below is suppose to refrence the example I left above. The script is suppose to check the first dropdown for a country and when the right option is choosen it disables dropdown 2.

I have been playing with the script and need other input.

var dropdown1 = "@:Country";

var dropdown2 = "@field:State";

var rightSelection = "United States";

function secondDropdown()

{

var firstDropdown = document.getElementsByName(dropdown1);

var firstSelection = firstDropdown[0].options[firstDropdown[0].selectedIndex].text;

var secondDropdown = document.getElementsByName(dropdown2);

if (firstSelection != rightSelection)

secondDropdown[0].disabled=true;

else

secondDropdown[0].disabled=false;

}

onload=secondDropdown;

/*(4) Everytime a selection is made, the function secondDropdown() is called. */

document.getElementById("caspioform").Value1_1.onchange=secondDropdown;

Link to comment
Share on other sites

Scrap what my last reply was. I posted the wrong code. below is the correct code. problem im having is i can get it to block/hide fields on load. I cant seem to get it to work on change. any ideas?

/*(1) Value1_1 is a reference to the first dropdown element */

var dropdown1 = '[@field:GSAO_recruiting_report_Viable]';

/*(2) Value2_1 is a reference to the second drodown element */

var dropdown2 = '[@field:GSAO_recruiting_report_Reason_if_no1]';

/*(3) The text in the first dropdown which if not selected will disable the second dropdown */

var rightSelection = 'no';

document.write (dropdown1)

function secondDropdown()

{

var firstDropdown = document.getElementsByName("EditRecordGSAO_recruiting_report_Viable");

var firstSelection = firstDropdown[0].options[firstDropdown[0].selectedIndex].text;

var secondDropdown = document.getElementsByName("EditRecordGSAO_recruiting_report_Reason_if_no1");

if (firstSelection != rightSelection)

secondDropdown[0].disabled=true;

else

/*secondDropdown[0].style.display ="none";*/

secondDropdown[0].style.display ="";

}

onload=secondDropdown;

/*(4) Everytime a selection is made, the function secondDropdown() is called. */

document.getElementById("caspioform").firstSelection.onchange=secondDropdown;

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...