I should have mentioned that I changed the HTML as well. I added an
ID to the submit button (submit-member). Notice how the event is
being triggered now: $('#submit-member').click(function() {...});
Since var username = $(this).prev().val() is appearing inside the
click method, $(this) refers to the submit button, prev() refers to
the previous sibling of that button, which should be the text input,
and val() refers to the value of that text input.
Now I'm wondering, though, what you're trying to accomplish with the
code. As Doug noted, it doesn't look like you really need a form at
all to do what you're trying to do. But it's kind of hard to advise
on that without knowing the larger context.
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Jan 3, 2007, at 8:53 PM, Daniel McBrearty wrote:
<html>
<head>
<script src="scripts/jquery.js"
type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#submit-member').click(function() {
var username = $(this).prev().val();
$("#member_info").html(username);
return false;
});
});
</script>
</head>
Ok, I'm looking at this. I moved the js into a seperate file. I am
calling the function OK when the button is clicked. But something
seems wrong with
var username = $(this).prev().val();
which is ending up as undef.
I don't actually understand this line - how is it getting the value
out of the form? "this" seems to be the button itself.
I also tried something like
var username = $("#username").val();
to try to select the text box directly and get the value, but no
joy either.
thanks again ... gonna sleep now :-)
--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/