Click to See Complete Forum and Search --> : Display cell content based on user input without buttons!
PHP_Idiot
04-07-2009, 12:38 PM
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?
JVassie
04-07-2009, 12:46 PM
I'm afraid I don't know the exact code you need to use, but it sounds like your problem would be solved by using JavaScript.
You need to use the onChange property of the MembershipNo input , and use it to call a JavaScript function which looks up the first and last names assosciated with that membership number, and then places them in the appropriate text fields.
This page has some useful examples of how to use the onChange method.
http://www.w3schools.com/jsref/jsref_onchange.asp
HTH
James
PHP_Idiot
04-07-2009, 12:59 PM
Darn I was hoping I could avoid Java but I think I knew I would come up at some point!
Thanks a lot for the advice James, I've had a look at the link you attached but as I have NEVER used java before I think I better go and look at the basics first!!
Cheers :D
JVassie
04-07-2009, 01:02 PM
No problems, also something to remember that Java and JavaScript are two seperate languages, the latter being the one you will need :)
PHP_Idiot
04-07-2009, 01:20 PM
Java and JavaScript are two seperate languages, the latter being the one you will need :)
Something else I learnt today!!
Anyone else ever wish all this could be just downloaded into your brain like the big plug they used in Matrix!
djjjozsi
04-07-2009, 02:13 PM
Hello,
http://phpcode.hu/ajax_updater/
in this site you can list your table's structure, its using a dropdown to populate textfields for table update, but its a piece of cake to change the dropdown into a normal textfield input field. Its using an onChange event for the input element, but you can use onKeyup (if you start writing a number it will select)
After you see the printed input boxes , you can extend with a submit button and add new textfields (just change the php code which is generating the input boxes).
This won't solve your problem in 100% but at least in 75% :)
got a question, ask.
jjozsi
PHP_Idiot
04-07-2009, 06:01 PM
Hi dj
Thanks for the link
I filled in the details on the link you sent me but when I upload it all it shows is a dropdown box with ====== as it's content!
Not sure what I'm doing wrong, I'll try again tomorrow, bedtime for me soon!
Thanks for the help.
Weedpacket
04-07-2009, 09:42 PM
I can't work out how to do this, but I suspect it may involve Java[Scrit] (although I desperately hope it doesn't as I have never used it!).Since you're talking about having the browser do something in response to user input, then PHP is not involved. PHP doesn't know anything about "buttons" or "user input". I wrote this some time back on the subject. (http://www.phpbuilder.com/board/showthread.php?s=&postid=10453973#post10453973).
djjjozsi
04-08-2009, 02:35 AM
I filled in the details on the link you sent me but when I upload it all it shows is a dropdown box with ====== as it's content!
In the generated code, in the first comment you can see how you need to name the php file. If you don't know much, i suggest watch that video tutorial how to set up the mysql connection on the bottom of the site.
If you make the steps, the result will be a dropdown list with your table entries, if you select a value, the connected data and the input fields appear.
Then you need to change the dropdown list to a textfield (in the php)
It sounds difficult, but if you need dynamic change just javascript is not enough.
PHP_Idiot
04-08-2009, 02:56 PM
Since you're talking about having the browser do something in response to user input, then PHP is not involved. PHP doesn't know anything about "buttons" or "user input". I wrote this some time back on the subject. (http://www.phpbuilder.com/board/showthread.php?s=&postid=10453973#post10453973).
As you probably guessed from my screen name I didn't know that, hence the question...
but thanks to the helpful comments I'm on my way to solving it...albeit slowly!
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.