Re: Question on onkeypress or keyCode event trigger
- From: AwefulService@xxxxxxxxx
- Date: Fri, 29 Feb 2008 12:23:20 -0800 (PST)
On Feb 29, 12:46 pm, AwefulServ...@xxxxxxxxx wrote:
Hi,
I attempt to create HTML ordered or unordered list function here.
Start with IE7...
function addList(obj,lt) {
var theBody = document.getElementById(obj);
var ul = document.createElement(lt);
theBody.appendChild(ul);
var li = document.createElement('li');
ul.appendChild(li);
Probably I should have made this part clearer, the following code
block did not work,
care to explain why and how to fix it? thks.
var keyCode = event.keyCode;// block ends
// if (obj.type == "keydown" || obj.keyCode == 13)
if (keyCode == 13 || document.onkeypress) {
theBody.ul.appendChild(li);
return false;
}
}
<form action="" method="post">
Data entry:</br>
<textarea name="stuff" cols="60" rows="8"></textarea><br/>
<input type="button" value="Add unordered list"
onClick="addList('stuff','ul');"><br/>
<input type="button" value="Add ordered list"
onClick="addList('stuff','ol');"> <br/>
<input type="reset" value="reset">
</form>
What am I doing wrong?
Thanks.
.
- References:
- Question on onkeypress or keyCode event trigger
- From: AwefulService
- Question on onkeypress or keyCode event trigger
- Prev by Date: Re: Best way to define "private" functions
- Next by Date: Re: how work .animate
- Previous by thread: Question on onkeypress or keyCode event trigger
- Next by thread: Querying words instead of phrases
- Index(es):