Jump to content
  • 0

Allow deleting only when value in the field=Delete


Mylene

Question

4 answers to this question

Recommended Posts

  • 0

Hi Mylene, 

 

That's easy. You should add Virtual Field, where users will type "Delete". Use the following code:

 

<SCRIPT LANGUAGE="JavaScript">

var stat=document.getElementById('cbParamVirtual1').value;

if (stat ==!'Delete')
    {
 
  document.getElementById("Mod0DeleteRecord").style.visibility = 'hidden';

    }



</script>

 

Happy Holidays

 

 

 

Link to comment
Share on other sites

  • 0

You can try:

<script>
var stat = document.getElementById('cbParamVirtualX');
var hideShowDelete = function (event)
{
    if (stat.value.toLowerCase().indexOf('delete') !== -1)
    {
        document.getElementById("Mod0DeleteRecord").style.visibility = 'hidden';
    }
    else
    {
        document.getElementById("Mod0DeleteRecord").style.visibility = 'visible';
    }
};
stat.addEventListener('input', hideShowDelete);
</script>

 

This revised code has the advantages of:

  1. Case insensitivity
  2. Ability to respond to user input instead of just the initial value
Link to comment
Share on other sites

  • 0

Try this one: 

 

<SCRIPT LANGUAGE="JavaScript">

document.getElementById("Mod0DeleteRecord").style.display = 'none';

function MyFunction()
{

var stat=document.getElementById('cbParamVirtual1').value;

var del = "Delete";
if(stat==del)
    {
 
  document.getElementById("Mod0DeleteRecord").style.display = 'initial';

    }
else 

    {document.getElementById("Mod0DeleteRecord").style.display = 'none';

     }
 }


document.getElementById('cbParamVirtual1').onchange=MyFunction;


</SCRIPT>

 

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