I've tried this several different ways with no luck (and my coding skills are admittedly a bit lacking, but I'm learning) and if it has been addressed somewhere else, I can't seem to find it anywhere.
Here's what I am trying to do:
I have a registration form that asks for the user to choose the hospital that they work at. I have a database table set up with the addresses and contact info for each hospital and I would like for the user to choose their hospital and then have the corresponding values pulled into hidden fields (and published right below the select box if possible though that is really not important). So basically I they pick their hospital and the form grabs the values so I don't have to worry about people entering the wrong address or different people typing it in differently. Seems like it should be pretty simple, but I can't get it to work. The data would be getting posted into CB from there so the fields should be able to have the name/id like cb_address etc and they should get pulled in automatically via the CB register plugin, right? Is this easy and I just don't get it or is there something that I'm missing?
Anyone have any experience with this sort of thing? Any help would be very much appreciated, I've tried everything I can think of and will continue to work on it for a while...
More often than not, I figure these things out within a few hours of breaking down and posting like this, but it's very late and I may let it rest until tomorrow but if someone who knows what they are doing wants to offer a solution that would be awesome...
Here's what I am trying to do:
I have a registration form that asks for the user to choose the hospital that they work at. I have a database table set up with the addresses and contact info for each hospital and I would like for the user to choose their hospital and then have the corresponding values pulled into hidden fields (and published right below the select box if possible though that is really not important). So basically I they pick their hospital and the form grabs the values so I don't have to worry about people entering the wrong address or different people typing it in differently. Seems like it should be pretty simple, but I can't get it to work. The data would be getting posted into CB from there so the fields should be able to have the name/id like cb_address etc and they should get pulled in automatically via the CB register plugin, right? Is this easy and I just don't get it or is there something that I'm missing?
Anyone have any experience with this sort of thing? Any help would be very much appreciated, I've tried everything I can think of and will continue to work on it for a while...
More often than not, I figure these things out within a few hours of breaking down and posting like this, but it's very late and I may let it rest until tomorrow but if someone who knows what they are doing wants to offer a solution that would be awesome...
Hi zandergraphics,
A bit hard to comment without seeing the form or any code.
Normally I'd do this by creating a hospital drop-down list from the database table using the record id as the option value.
Then in the OnSubmit code you can look up that record to get whatever other info you need.
Bob
A bit hard to comment without seeing the form or any code.
Normally I'd do this by creating a hospital drop-down list from the database table using the record id as the option value.
Then in the OnSubmit code you can look up that record to get whatever other info you need.
Bob
I've tried quite a few different variations of the code, but this was the most recent (in onsubmit after field):
The form can be seen here:
http://www.nnpnetwork.org/2009/register.html
Everything submits fine and if I plug some info into the hidden field for the address it goes in just like it should. The problem appears to be with calling the query.
<?php
$sql ="SELECT address FROM `jos_nnpn_hospitals` WHERE `hospital_name`=".$_POST['cb_hospital']."";
$database->setQuery($sql);
$result = $database->loadObject();
$_POST['cb_address'] = "$row->address";
?>
The form can be seen here:
http://www.nnpnetwork.org/2009/register.html
Everything submits fine and if I plug some info into the hidden field for the address it goes in just like it should. The problem appears to be with calling the query.
This topic is locked and no more replies can be posted.