Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

multiple autofill dropdowns from db -php quesion

Status
Not open for further replies.
Joined
Jan 19, 2007
Posts
2,207
Reaction score
47
Ok a bit tricky to explain but hopefully someone will understand me and can help :)


I have a series of 3 dropdown boxes.
You selct and option from the first and it updates the options in the second drop down.
You then select an option in the second and it fills the options in the third drop down.

Now I've managed to create all of this with javascript code. But this is with the all of the options and information being in the html. So anyone can view source and see all of the options which I'd prefer not to happen.

That's the first and smaller issue. The second issue is that my test script (javascript) which achieves the above, is only for a few 50-ish entries for each dropdown. My final project could have a few thousand entries in a db that I would need to display as entries, and as entries are added to the database I would want these options to be automatically available for people to select in the dynamic form...

I'm looking for a solution which the entire database wouldn't be exposed by people viewing the source of the page.

I think if javascript is used (even by php pulling the the information by arrays to create the javascript) then this information would be exposed. Or is there a way to hide the javascript code (containing the db info) inside the page header or hiding it somehow in the body.

Or should I forget javascript altogether and just do something with php and reloading the page...

A bit of a tricky one - any thoughts appreciated...
 
The only way you could do this would be using AJAX, so your Select Box2 OnChange would pass selectbox1's value to the script process it and return the results, your javascript would then populate box2 and so on.

My AJAX sucks and outsource it, but a little search on the net for PHP Ajax will set you right.

Oh yeah because you are using javascript to run a php query and then pulling it back into html means you don't need to convert the page to php because the java will work between the php and html. The database will need to be mysql and the population/query will need to be php but the calling page with the ajax in can be html.
 
Thanks skinner I'll look into ajax, and try and find a script, just have no experience of ajax so if there's another way to do it with javascript and php alone it would be a better solution for me.

The database is mysql. And I know that if I just use php alone then I'll need page reloads on each dropdown selection with php being server side.

My solution so far with php gathering all the options from the database and loading them into the javascript code should work, but my big convcern is having the whole database available to anyone who views the source of the page. (plus there are a lot of options pulled from the db).

Maybe your suggestion of ajax will do this in a secure and fast way - any tips? I'll do a few google searches.
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

No members online now.

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom