Friday, March 13, 2009

Homework 4 Register Now Part 2

Okay, I finally got it -- BUT I have to admit that this was a trial-and-error 'shot in the dark' process for me -- and I'm sure that I wrote way too much code. My unsuccessful attempts included playing with W3S's example for onkeypress events (which I just didn't understand at all), plus mimicking W3S's onkeyup event (which didn't work) and finally mimicking W3S's onclick event (again which didn't work). I reviewed notes from class about Changing Classes but that was unsuccessful too. I finally ended up using the html code from W3S's onclick event AND the js code from W3S's onkeyup event. I'm sure this can't be right...

I suspect at this point that my js code in the html doc is what's driving everything right now -- as nothing seems to relate to my external js script??? My biggest concern right now is that I still fundamentally do not understand how html and js drive AND relate to each other (I think I'm getting confused with how the variables in the external js script 'match' with the information in the html doc) -- for example, I understand what 'x' means in my external js sheet (the id), however when I tried to call the function within my html code by typing in onkeyup="copyTextInput (id);" /> or onkeyup="copyTextInput ('username_field_2') ;" /> or onkeyup="copyTextInput ('username_field_1');" /> the script just didn't work (and I'm not sure why because this made more sense to me then what I ended up doing). Also, in my external js script -- I don't get where the 'y' comes in as I'm certainly not referring to a 'y' anywhere in the html code...


here's a sample of my html code:

input id="username_field_1" class="field_box" type="text" name="username" onkeyup="document.getElementById('username_field_2').value=
document.getElementById('username_field_1').value;"


and here's a sample of my external sheet js code:

function copyTextInput(x) {
var y = document.getElementById(x).value;
document.getElementById(x).value = y.toCopyTextInput();
}
Here's the link to my webpage:

http://onepotcooking.com/annmariegatti/class4/register_now_rev.html

No comments:

Post a Comment