11/01/05 CISC103 Fall 2005
First, a reference for Spanish er verbs (since we are using that an an example):
http://www.studyspanish.com/verbs/lessons/juster.htm
Some questions from last time:
(1) Can we make the text in a form field right justified?
I haven't found a way to do it, at least not in standard HTML4.01.
This link, which is a link directly into the HTML4.01 spec, lists all the attributes
that can go on a form input field. None of them look like they would do the trick.
http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.4
The better way will be to construct the table itself using Dynamic HTML, which is
what we are working our way up to. So there will be a way to do it, just not using
the tools we have learned so far (i.e. by setting the "value" of a text field in
a form.
Setting align="right" on the
element doesn't do it either.
Late breaking news... I thought that align="right" on the input element wouldn't
work, but apparently it does... oh well...
(2) Can we strip off the "er" on the infinitive of a verb like "comer" rather than just
typing in "com"?
This we most definitely can do, and we'll learn about that today.
References:
Section 12.4 in Deitel/Deitel/Goldberg
Project 1 in Essentials for Design, JavaScript Level 2 (not 1).
To strip off the er on comer, we use a method of the String class, like this:
function computeStem(infinitive)
{
// infinitive should be a string like "comer";
var positionOfErEnding = infinitive.lastIndexOf("er");
var stem = "";
if (positionOfErEnding == -1)
{
window.alert("Infinitive does not end in er");
stem = "";
}
else
{
stem = infinitive.slice(0,positionOfErEnding - 1); // pick off the stem
}
return stem;
}
(3) How can we get the accent on the e in the vosotros form of comer?
We got the tu with the acute accent by writing the following in the XHTML instead of tu:
tú
So we tried putting "éis" in the string, but that didn't work. That doesn't
work in JavaScript.
Here's what we have to do instead.
First, look at at table like this one to get the character code:
http://www.cookwood.com/html/extras/entities.html#char
The lowercase e with an acute accent (one that rises from left to right) is written
eith é in HTML and XHTML, and the character number in Unicode is: é.
So we use the following:
var vosotrosEnding = String.fromCharCode(233) + "is";
p. 384 of your pink book:
lastIndexOf(substring, index)
searches for the last occurrence of "substring" in the given string, starting
from index, and going from the end towards the beginning, (or from the end if index
is not given.)
var infinitive = "comer";
var locationOfEr = infintive.lastIndexOf("er");
If the string is not found, it returns -1.
|