Jump to content

Char Code Event?


unemployment

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

Archived

This topic is now archived and is closed to further replies.

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