duanquanzhi5560 2014-12-19 09:33
浏览 27
已采纳

一键保存所有文本框中的数据

this is my first post after joining the forum.

First of all, I am not a programmer. My field is of Building design and Architecture. I work for an Architectural company.

I have a great interest in programming and I started learning php, mysql, html css and jscript, to develop a timesheet application for the company. The web application was created and successully implemented in April this year...! However, all these are purely 'self learning', and it has its own downsides as well. This was just a small intro..., let me come to what i request help on. This is for further development of the application.

I have a page to edit the 'utilization' rate of each employee, based on their designations. So the page has all the designations listed as , next to which a textbox, for the user to fill in the utilization rate. Scenario is that the user will not save each designation's utilization rate immediately after filling it. User will keep going till he fills the last item and then hit the submit button to save. Now, in php I can get all the values from the Request Array. But, how will I know which designations these values belong to? So, what i have as a solution is to name the textboxes with the designation_ids as suffix. May be like;

utilTextbox_1, utilTextbox_2, utilTextbox_3 etc...

Then when the form is submitted;

Check each Request Array element to see if its name starts with 'utilTextbox'

If Yes, split it using '_' to get the designation_id

Update the db table with the value of the text box

Check the next Array Element.....and so on...

is this the correct method or is there a better way of doing this?

  • 写回答

1条回答 默认 最新

  • drxyaox153896 2014-12-19 09:36
    关注

    You can have array as names in html forms. So something like utilTextbox[1], utilTextbox[2], utilTextbox[3] will work perfectly fine. In php you will get an array in $_REQUEST and you need not to convert in an array because it is already an array.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#网络安全#的问题:求ensp的网络安全,不要步骤要完成版文件
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥20 使用Photon PUN2解决游戏得分同步的问题
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序