Hi,

I am trying to create a 'simple' admin page where certain (authorized) people can update data in the database or add new info to it. The issue i've run into is after i created the form and have all the fields how do i tell which one(s) the user has typed into/edited so i can use that info in a query.

I was thinking i might need to use the onchange event but not sure how i'd track each field that was changed and then update only those, i even checked some of phpmyadmin's code to see how they do it but couldnt really figure it out.

Help plz

Recommended Answers

All 4 Replies

Well that's more of a PHP thing, not so much with JavaScript. You can't do alot(anything?) in Javascript to interact with a database.

well the thing is i'm not interacting with the database at this point. The 'fields' i'm referring to are the html form fields where a user would type things such as a name, etc.

e.g. If i had:

Search for a Plant to update:
Scientific Name _____
Common Name _____
[Search]

How do i tell which field the user has typed in here (sci name/com name or both) so that i can pass that text into a query later on.

var blah = document.getElementById(<textbox id>);
if(blah.value == "")
  alert("blah is empty");

You can just validate it through javascript(Or to check if that field has some value or not.) But, Its much easier if you do it in php. eg.

if(isset($_POST['sci_name'])){
echo "Scientific name is ". $_POST['sci_name'];
}
if(isset($_POST['name'])){
echo "General name is ". $_POST['name'];
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.