I have a php page that include a ComboBox and a TextBox, I need the TextBox change his value automatically depending on the value selected in the ComboBox.
I have tried with onchange event but I can't pass values between javascript and PHP.
You need the textbox to change its value depending on a combo box selection. This must mean there is an onto mapping between Cbox values and Tbox values. Further it seems as if this mapping resides on the server side, as I can gather from your description of the problem.
In this scenerio the easiest way is, to do a quick Ajax call to the server with the new Cbox value when it changed, and fill the Tbox with its corresponding value on the Ajax reply.
Otherwise you will have to send the relational values and store them in a Javascript array making them accessible at the Client/Browser side, when the onChange for the Cbox is triggered.
I can lend you some code to do it, if you are stuck in syntatic overload.
Knowledge is that which can be shown to be the case, and Intelligence is the method one uses to deploy the demonstration of what is the case, everything else is Information.
Ok, I will show you the code, but it will have to be done in steps.
(1) You will need the Ajax support routines that I can provide.
(2) The Server request handler will be filled in by you, using a sort of prototype I can outline.
(3) The HTML support with element ID's is on your page and plate.
How it will work.
(A) When the onChange for the Combo box triggers, it will call a Javascript function that will prepare an Ajax call to a specific ServerRequestHandler sitting on your Website - RequestText.php.
(B) When the request returns to the Browser, a Javascript function will unwrap the answer and place it into the Text Box.
When you are ready to continue let me know.
Knowledge is that which can be shown to be the case, and Intelligence is the method one uses to deploy the demonstration of what is the case, everything else is Information.
Knowledge is that which can be shown to be the case, and Intelligence is the method one uses to deploy the demonstration of what is the case, everything else is Information.
Fantastic!! Code works perfectly...
Now if you were so kind, I would appreciate it if you could show me how to do it when the combo is filled with data from a database. The table is simple, it has two fields: code of country (P_codprocedencia) and Name of country (P_procedencia):
You can generate the javascriot array the same way you are generating the options.
var carMAP = [] ;
carMAP['P_codprocedencia'] = 'P_procedencia';
but you will use the correct syntax.
I do not program Php the way you have listed it, therefore I could not provide similar type coding.
Knowledge is that which can be shown to be the case, and Intelligence is the method one uses to deploy the demonstration of what is the case, everything else is Information.
Bookmarks