dri98076 2014-06-04 19:56
浏览 13

使用当前选定的项目实现autosuggest /选择UI +单独的div

I want to build a UI where a user selects several products, and those products are shown to the user, and then various computations are made on those selected products. So:

  • div1: area where user selects products
  • div2: current product selections are shown
  • div3: results (showing results of computations made on user selections)

I am primarily a back-end PHP programmer, and by no means a JS of front-end programmer programmer, so nuances of jQuery, JavaScript or working knowledge of them, and such are not my area of expertise. I can probably implement this without JS, and have it work, without all the dynamic content. It maybe not be as immediate but it will work. Although, this is a good opportunity to try dynamic content, and when it comes to the world of JS, I figure gotta start somewhere.

I think ideally this can be implemented by using an autosuggest->select widget in div1, where I can preload existing products from DB. Then, something in div2 to show current user selections. Results in div3 can then be either computed on the fly with JS, but since majority of the computations are done in PHP I figure I will do those on the back end, and display results wither via AJAX or via page reload (form submit).

So, while I figure I can make it all completely dynamic (aka JS), rewriting existing PHP code into JS is probably not exactly beneficial.

Question: How do I do UI to support features for div1 and div2 keeping in mind that I am not an expert on JS or jQuery. And how do I pipe those selections via POST to my PHP script? After that my intentions is to reload the page with results in div3, keeping div1/div2 same as user left them before page reload. I

  • 写回答

2条回答 默认 最新

  • dplht39359 2014-06-04 20:09
    关注

    Use jQuery & Ajax Calls to achieve this. You need to follow something like this -

    • Add jQuery to your application
    • Assign some event listeners to your product selection in div 1
    • Using the even listeners, upon selection of some product in div 1, show it in selected items in div 2.
    • At this point you can make an ajax call to your server where your PHP code does the computation & send the list of products you selected via an Ajax call.
    • The server can then process stuff & respond back to you with the data you need to show.
    • You capture this data in your ajax request response & then populate your div 3 with this.

    Showing how to do the whole thing would be a lot of code, let me show you some references that will help you -

    Hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真