在没有refre的第一个下拉列表的onChnage()上从数据库填充下拉菜单 [英] Populating drop down menu from databse on onChnage() of first dropdown without refre

查看:115
本文介绍了在没有refre的第一个下拉列表的onChnage()上从数据库填充下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是php和ajax的新手,当我点击第一个下拉元素然后在第二个下拉列表中所有元素showl来自数据库时我面临的问题。

我的意思是我有三个下拉列表1.类别来自数据库2.品牌来自数据库根据第一个下拉列表的内容。和3.价格是静态的。

当我在每个onChange(而不是ajax)上做这些事情时,整个页面都是令人耳目一新的,我不想要。和ajax我面临一些问题,比如我在一个页面中有两个php页面,所有下拉都是写的,在socond php页面中只有品牌'的下拉写入我的意思是当我从数据库调用任何类别然后在品牌下拉列表中类别来自数据库,但假设我选择了一个COPUTER,那么计算机相关品牌来自数据库并取代现有的下拉菜单。我不想替换下拉列表我想清除第一页下拉列表的内容并填充来自第二页的内容。


这里是代码:

selectbrand.js

Hi everyone,
I am new in php and ajax, i am facing the prob while i click on element of first drop down then in second dropdown all element showl come from database.
I mean i have three dropdown 1. category which comes from database 2. brand which comes from databse according to content of first dropdown . and 3. price which is static.
when i am doing these things without ajax on every onChange() thw whole page is refreshing that i do not want. and with ajax i am facing some prob like i have two php pages in one page all drop down is written and in socond php page only brand'' s drop down is written i mean when i ma calling any category from databse then in brand dropdown category comes from database but suppose i am choosing a COPUTER then computer related brand comes from databse and replace the existing drop down . i do not want to replace the drop down i want to clear the content of first page dropdown and populate the content which comes from second page.

here is code:
selectbrand.js

展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号

推荐答案

而不是返回HTML代码来替换下拉列表,返回由特殊字符分隔的字符串,您可以使用该字符填充下拉元素。或者,您可以使用JSON或XML。


PS。发布代码时请使用代码标签。请参阅如何提出问题
Instead of returning the HTML code to replace the drop down, return a string delimited by a special character which you can use to populate the drop down element. Alternatively, you can use JSON or XML.

PS. please use code tags when posting code. See How to ask a question.



不是返回HTML代码来替换下拉列表,而是返回由特殊字符分隔的字符串,您可以使用该字符来填充下拉元素。或者,您可以使用JSON或XML。


PS。发布代码时请使用代码标签。请参阅如何提出问题





forx回复。现在我正在使用你的解决方案,但在javascript populate函数不起作用。点击第一个下拉列表,它删除第二个下拉列表中的所有元素但是如果填写第二个下拉列表它不起作用..

javascript代码

Hi,
thanx for reply .now i am using ur solution but in javascript populate function is not working . on click of first dropdown list it remove all yhe element of second dropdown but in case of filling second dropdown its not working..
javascript code

展开 | 选择 | Wrap | 行号


显示你调用dropdown()的代码/行。
Show the code/line where you call dropdown().


这篇关于在没有refre的第一个下拉列表的onChnage()上从数据库填充下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆