填充表时两个相互依赖的查询

发布于 2024-08-24 06:53:12 字数 421 浏览 11 评论 0原文

我有 2 个疑问。一种是填充填充下拉列表的数据集,另一种填充表行的其余文本框。我想知道如何填充整个下拉列表,然后使 selectedvalue 成为其他查询中的值?

例如 -

dataset query = select hobby from hobbies
other query - select name, dob, address, hobby from employee

现在表看起来像这样 -

Name DOB         Address       Hobby
Sam  01/10/1988  111 main st   Dropdownlist(n number of records)

现在在下拉列表中,我希望将员工表中的爱好填充的所有爱好作为所选值。

I have 2 queries. One is populating a dataset that populates the dropdownlist and the other populates rest of the textboxes of a table row. i want to know how can i fill the entire dropdownlist and then make selectedvalue the value from the other query?

e.g -

dataset query = select hobby from hobbies
other query - select name, dob, address, hobby from employee

now the table looks like this -

Name DOB         Address       Hobby
Sam  01/10/1988  111 main st   Dropdownlist(n number of records)

Now in the dropdownlist I want all the hobbies populated with the hobby in the employee table to be the selected value.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眸中客 2024-08-31 06:53:12

不确定我是否理解,但我会尝试使用一些伪代码,

  ## fetch hobbies and employees from db
  dataset hobbies = select hobby from hobbies;
  dataset employees = select name, dob, address, hobby from employee;

  ## loop through all employees
  foreach employee in employees{

    print employee->name;
    print employee->dob;
    print employee->adress;

    ## second loop to print hobbies dropdownlist for each emplyee
    print "<select>";
    foreach hobby in hobbies{
      boolean is_selected = (employee->hobby == hobby);
      print "<option value=\"".hobby."\" selected=\"".is_selected."\">".hobby."</option>";
    }
    print "</select>";
}

这不是正确的 html 或任何内容,只是证明概念的伪代码。

Not sure if i understood, but ill try with some pseudo-code

  ## fetch hobbies and employees from db
  dataset hobbies = select hobby from hobbies;
  dataset employees = select name, dob, address, hobby from employee;

  ## loop through all employees
  foreach employee in employees{

    print employee->name;
    print employee->dob;
    print employee->adress;

    ## second loop to print hobbies dropdownlist for each emplyee
    print "<select>";
    foreach hobby in hobbies{
      boolean is_selected = (employee->hobby == hobby);
      print "<option value=\"".hobby."\" selected=\"".is_selected."\">".hobby."</option>";
    }
    print "</select>";
}

This is not correct html or anything, just a pseudocode to proof concept.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文