thanks a lot guys. That 's really a great response.

I got it to basically work, now I'll read through your suggestions and
clean it up. I'm still learning ... :-)

thanks again.

Daniel

On 1/4/07, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> Okay, so Mike and Blair got back to you before I could, but I'm going to
> answer anyway.
>
> They're right, of course, that you need to return false, because you want to
> stop the default action.
>
> One of the great things about jQuery is that it lets you easily separate
> behavior from content. So I would suggest pulling the onclick handler out of
> the input. Here is what it would look like with the script in the <head>,
> but ideally you should put it in another file and include it the same way
> you include jquery.js:
>
> <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>
> <body>
>   <p id="member_info"></p>
>
>   <form name="find_member" action="" method=GET>
>     <input type="text" size="30" name="username">
>     <input type="submit" id="submit-member" size="30" value="Find by
> Username">
>   </form>
> </body>
> </html>
>
> You should also put DTD, etc. in there. I'm just taking shortcuts for the
> sake of brevity.
>
>
> --Karl
> _________________
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
>
>
>
>
> On Jan 3, 2007, at 7:37 PM, Daniel McBrearty wrote:
>
> Hi
>
> Just getting into using js to do things. I'm just experimenting right now.
>
> Here is my example code:
>
>
> <p id="member_info"></p>
>
> <script type="text/javascript">
>   function findMember(form){
>     $("#member_info").html(form.username.value);
>   }
> </script>
>
> <form name="find_member" action="" method=GET>
>   <input type="text" size="30" name="username">
>   <input type="submit" onClick="findMember(this.form)" size="30"
> value="Find by Username">
> </form>
>
> now what happens when I fill in a value and click is that the value I
> entered into the text box appears in the "member_info" <p> ... but
> disappears again almost straight away.
>
> any ideas?
>
> thanks. the lib looks nice and clean BTW.
>
> Daniel
>
> --
> 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/
>
>
>


-- 
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/

Reply via email to