Jump to content

Recommended Posts

I found this snipped of code online, but I don't know what 'e' is.  Can someone please explain this to me?  I am trying to delete a div when backspace is pressed.

 

function backspace_delete(e) 
	{
		if (!e) 
		{ 
			// IE reports window.event instead of the argument
			e = window.event;
		}
		var keycode;

		if (document.all) 
		{
			// IE
			keycode = e.keyCode;
		} 
		else 
		{
			// Not IE
			keycode = e.which;
		}

		if (keycode == 
		 {
			if (document.all)
			{
				// IE

			} 
			else 
			{
				// Non IE

			}
		}
	}

Link to comment
https://forums.phpfreaks.com/topic/239234-char-code-event/
Share on other sites

I got this working, but now I have a new issue. Once I have an empty value in my input the event fires, but I only want it to fire if the input field was blank and then I hit backspace, not if I do both of those actions at the same time.

 

if (keycode == 8 && with_field.value == '')
		 {
			if (document.all)
			{
				// IE
				removeElementById(with_input.lastChild.id);
			} 
			else 
			{
				// Non IE
				removeElementById(with_input.lastChild.id);
			}
		}

Link to comment
https://forums.phpfreaks.com/topic/239234-char-code-event/#findComment-1229082
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.