Textbox to update another textbox by reading a table

Posted on 2011-10-05
Last Modified: 2012-05-12

I have a table (say "testtable") as below which I read into PHP:


I have a form called "testform". On this are two text boxes, one called "textbox" and the other called "textanswer".

I'm trying to type a number into "textbox", get it to look up this number on the ID field of the table mentioned above and put the corresponding colour into "textanswer".

Usually I would do this by having "textbox" set up as a dropdown field and pull the second column into "textanswer" when changed. However, in this case I can't do this because if a colour is not found on the table, the user needs to be able to type in their own value in "textbox". Also, there will be some 15000 records in the table.

Can someone please show me how to set this up, if possible?

Many thanks in advance
Question by:kbit
    LVL 8

    Expert Comment

    You can still do this by having the dropdown, you need an extra value at the end as "OTHER" and if a user selects that, one blank textbox appears and then you can process the form.


    Expert Comment

    find in google easy

    Accepted Solution

    I;m thinking a lazier way would be to let the user type their value in "textbox", make them press save and then PHP would do all the checking and reload the same page with or without the relevant "textanswer".

    Another way would be to submit the form with the onchange of "textbox", again PHP would do the work.

    Author Comment

    Anyone in the Javascript zone have any ideas? There has to be a way of doing this without submitting through PHP!

    Author Closing Comment

    No other method was found, this one is working fine

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now