Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
226 views
in Technique[技术] by (71.8m points)

php - In how many ways can i get value from a html select tag WITHOUT submitting the form? And what are ways that real websites use for security purposes?

i am learning php along with mysql and so developing a e-comm site it is very exiting when i get hindered by some error but this time it just a html thing that has stopped my constuction.

so, i have to populate 2 <select> tags in a addProduct form for Category and sub-category but i need to work on onChnage event for category select list, as to populate the sub-category select list on basis of the user selection in category select list. i have searched a lot and some how i can do it but i want to know what are the possible ways and what is the safest way? also can i build a php function to do this if yes how to get the element value without submitting the form since it will submit all the form data that will empty all other fields. thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

onChange events are handled by javascript, PHP is finished processing before the user sees the loaded webpage.

To do what you are asking, you will want to utilize javascript/AJAX to update the page "on the fly"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...