如何使用php和html根据组合框选择的更改自动更改输入文本框的值

时间:2023-01-27 20:14:52

Lets say there is a combobox with 3 values:a,b,c. There are also 3 text boxes. There is a database with 1 table which contains 4 columns. Now, how exactly can I update the values of the 3 inputboxes whenever I select a different value in the combobox. Lets say combobox represents the data in column 1 of the database table, textbox1 reporesents data for column 2, textbox2 for column3 and textbox3 for column4, so that the values of the text input boxes changes accordingly.

让我们说有一个组合框有3个值:a,b,c。还有3个文本框。有一个包含1个表的数据库,其中包含4列。现在,每当我在组合框中选择不同的值时,我究竟能如何更新3个输入框的值。让我们说组合框表示数据库表第1列中的数据,textbox1表示第2列的数据,第3列的textbox2和第4列的textbox3,因此文本输入框的值会相应地更改。

I am really sorry for being vague. Hope someone can still help me out. This has to be done using php html ajax and mysql.

我很抱歉模糊不清。希望有人能帮助我。这必须使用php html ajax和mysql完成。

1 个解决方案

#1


0  

this has to be done in javascript mainly. something like this (no valid code just mockup)

这必须主要在javascript中完成。像这样的东西(没有有效的代码只是模型)

<select onchange="changeInputBoxes(this)"...> .... </select>
<script>
function changeInputBoxes(){
document.getElementById("inputid").value = this.value;
...
}
</script>

but its really to vague.

但它真的很模糊。

#1


0  

this has to be done in javascript mainly. something like this (no valid code just mockup)

这必须主要在javascript中完成。像这样的东西(没有有效的代码只是模型)

<select onchange="changeInputBoxes(this)"...> .... </select>
<script>
function changeInputBoxes(){
document.getElementById("inputid").value = this.value;
...
}
</script>

but its really to vague.

但它真的很模糊。