Forum Moderators: coopster

Message Too Old, No Replies

Display cell content based on user input without buttons!

         

PHP_Idiot

3:29 pm on Apr 7, 2009 (gmt 0)

10+ Year Member



Confusing title I know, but wasn't sure how else to describe it!

I have an html table with 5 columns:
Position, Points, MembershipNo, FirstName, LastName
Position and Points are populated using a php $counter loop.
MembershipNo will be user inputted
FirstName & LastName - I want these to look up the membership number that has been inputted and display the associated First & Last names of the players.

However, I want it to do this on the fly, so as soon as each membership number is entered the names appear. What I do not want to do is to have to click a button either at the end of each row or at the end of the form to fill these values.

I can't work out how to do this, but I suspect it may involve Java (although I desperately hope it doesn't as I have never used it!).

Can anyone offer any advice at all please?

IanKelley

5:21 pm on Apr 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What you're looking for is AJAX (Google it), but it's a lot to tackle for a beginner.

rocknbil

8:41 pm on Apr 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What I do not want to do is to have to click a button either at the end of each row or at the end of the form to fill these values.

Short answer - onChange of the text field, execute some action.

<input type="text" onChange="some_action();">

Where some_action() can be simple Javascript (not JAVA - different technology,) or an Ajax request, as mentioned . . . OR . . . since you are familiar with PHP, a simple submit to your PHP script and allow the page to reload with retrieved values:

<input type="text" onChange="this.form.submit();">

However, these are always dangerous travels because 1) if Javascript is disabled, it won't work, and 2) many users don't know that "press enter" when in a text field submits the form. So basically, there is no familiar tool to update the form with. It may look and feel cleaner to you, but who's the site for, you or your users? :-)

PHP_Idiot

12:20 am on Apr 9, 2009 (gmt 0)

10+ Year Member



The page this is one will be in an admin area of the site, and used by myself and just a few others, this means I can make sure everyone knows they need javascript enabled.

I had been playing with an onkeyup but cannot get it to work inside the table, I haven't even started to look at updating with the database info yet, just getting it to work in some way at all would have been nice!

I really can't work out the best way forward, I want the two name fields to update as the user goes down the list adding the membership numbers so that they can check for errors as they go along, rather than press a button to complete all the fields and have to go back through it all rechecking everything.

I have had a suggestion of placing the data in an array, but I'm not sure how that would work either!

If anyone can either suggest an alternative method or help me develop the code I need I would be eternally gratefull. I have a very tight deadline now as the site is due to go live next Tuesday!

pretty pretty please!

[edited by: PHP_Idiot at 12:25 am (utc) on April 9, 2009]