drju37335 2018-07-05 12:40
浏览 135

用户添加选项后,在HTML select标签中选择新选项?

Currently I have a form that asks the user a series of questions, they answers those questions via a select tag object. Those options in the select tag are populated by a database via php and mySQL. If the user does not see an option that best fits the their answer, they are allowed to add in their own answer. They are then brought to a new page to register their new answer to the question. That form posts to a php script that then updates the data base and they are back to the original form with the questions with the newly added option now in the select tag. How would I go about making the newly added answer selected in the select tag after they are redirected? I have researched this idea and cant seem to find a answer. So im looking to bounce some ideas around if someone has one.

  • 写回答

1条回答 默认 最新

  • douchan7552 2018-07-05 12:46
    关注

    Are you pushing the new answers to the same database that you are pulling the options from in the first place?

    What I would recommend doing is getting the last inserted ID from the database and storing it in the users session, and then using that to automatically have the answer they just inserted selected by default.

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line