Okay, I made the changes and it kind of works!
But, first, did I put the return and do the things you wrote about in the previous post correctly?
<!Doctype HTML>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>tab button js</title>
<style type="text/css">
input, textarea, select{
margin:5px 0;
padding:5px;
background:#f5f5f5;
border:1px solid #d9d9d9;
border-top:1px solid #c0c0c0;
color:#000; /*Makes text black after user has typed it in.
In other words, when there is text in the input-field. This
makes it easier to read on the grey background after done typing */
font:1em "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif;
font-weight:bold;
border-radius:5px;
line-height:normal;
}
input:hover, textarea:hover, select:hover{
background:#fff;
border:1px solid #b9b9b9;
border-top:1px solid #a0a0a0;
box-shadow:inset 0 1px 2px rgba(0,0,0,0.3);
color:#000;
font-weight:bold;
}
input:focus, textarea:focus{
background:#fff;
border:1px solid #4d90fe;
box-shadow:inset 0 1px 2px rgba(0,0,0,0.3);
color:#333;
font-weight:normal;
outline:none;
}
select:focus{
box-shadow:inset 0 1px 2px rgba(0,0,0,0.3);
color:#000;
}
#tab{
height:35px;
width:100px;
border:1px solid #3079ed;
background:#4d90f3;
border-radius:3px;
box-shadow:none;
color:#fff;
cursor:pointer;
text-shadow:0 1px rgba(0,0,0,0.1);
}
#tab:hover{
background:#357ae8;
border:1px solid #2f5bb7;
box-shadow:none;
text-shadow:0 1px rgba(0,0,0,0.3);
}
#tab:active{
box-shadow:inset 0 1px 2px rgba(0,0,0,0.3);
}
label{
font-size:20px;
font-weight:500;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#sampleForm').prop('previousFocus', false);
$('#sampleForm :input:not(#tab)').blur(function() {
$(this.form).prop('previousFocus', this);
//this.form.previousFocus = this;
});
$('#tab').click(function(){
var form = this.form;
previousFocus = form.previousFocus;
var focusNext = false;
$(':input:not(#' + this.id + ')', form).each(function(){
if(focusNext === true){
this.focus();
focusNext=true;
}
if(this === previousFocus){
focusNext=true;
alert(focusNext);
}
return focusNext;
});
});
});
</script>
</head>
<body>
<legend align="center">Form</legend>
<form method="post" action="" id="sampleForm">
<label for=name accesskey=U class="verticallyCentredInput"><span class="required">*</span> Your Name: </label>
<input name="name" type="text" id="name" size="28" autocomplete="off" />
<br />
<label for=email accesskey=E class="verticallyCentredInput"><span class="required">*</span> Email: </label>
<input name="email" type="text" id="email" size="28" autocomplete="off" />
<br />
<label for=subject accesskey=S id="subjectLabel"><span class="required">*</span> Subject: </label>
<select name="subject" type="text" id="subject">
<option value="commt">Comments</option>
<option value="concr">Concerns</option>
<option value="bugs">Report a bug (issue)</option>
<option value="sales">Sales</option>
<option value="suppt">Support</option>
</select>
<br />
<label for=comments accesskey=C><span class="required">*</span> Your Comments: </label>
<textarea name="comments" cols="27" rows="3" id="comments"></textarea>
<hr />
<input type="button" id="tab" value="Tab">
</form>
</body>
</html>
By semi-working, 1.) it still alerts the value of focusNext, which I just have to remove.
[B]But, more importantly, when I manually focus on the first input and then click tab, it alerts true and then moves to the last input, not the email one…
Also, as you mentioned above, it does nothing if no input is focused on manually or if the last one is focused on, but first what can we do to get the order correct— meaning that once the tab button is clicked, it moves to the next form element (input, select, or textarea) ?[/B]