Jump to content
  • 0

Conditional Formatting on Submission Form


apatrick

Question

Hello-

I'm trying to apply conditional formatting to a drop-down box in a Submission Form DataPage. For example, when the user selects "Fail" from the drop-down box, I want the background of the box to turn red.

Here's the code I tried to use without success. I pasted this into an HTML block directly after the drop-down box.

 

<script>

var select = document.getElementById("InsertRecordPrint_Asmt_Rec");

select.onchange = function(){
    var selectedString = select.options[select.selectedIndex].value;
    if (selectedString == "Fail") {
document.getElementById("InsertRecordPrint_Asmt_Rec").style.color = "red";

}

Else {
document.getElementById("InsertRecordPrint_Asmt_Rec).style.color = "black";
}}

</script>

 

 

Any help would be greatly appreciated.

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
On 7/25/2017 at 0:17 AM, apatrick said:

Hello-

I'm trying to apply conditional formatting to a drop-down box in a Submission Form DataPage. For example, when the user selects "Fail" from the drop-down box, I want the background of the box to turn red.

Here's the code I tried to use without success. I pasted this into an HTML block directly after the drop-down box.

 

<script>

var select = document.getElementById("InsertRecordPrint_Asmt_Rec");

select.onchange = function(){
    var selectedString = select.options[select.selectedIndex].value;
    if (selectedString == "Fail") {
document.getElementById("InsertRecordPrint_Asmt_Rec").style.color = "red";

}

Else {
document.getElementById("InsertRecordPrint_Asmt_Rec).style.color = "black";
}}

</script>

 

 

 

Any help would be greatly appreciated.

 

I edited your code a little bit. Try using code below:

<script>
function myfunc(){
var select = document.getElementById("InsertRecordPrint_Asmt_Rec").value;
    if (select == "Fail") {
document.getElementById("InsertRecordPrint_Asmt_Rec").style.background = "red";

}
else {
document.getElementById("InsertRecordPrint_Asmt_Rec").style.background = "black";
}
}

document.getElementById("InsertRecordPrint_Asmt_Rec").onblur=myfunc;

</script>

Hope that helps :) Cheers!

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
Answer this question...

×   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...
×
×
  • Create New...