Maison > interface Web > js tutoriel > le corps du texte

script不刷新页面的联动前后代码_javascript技巧

WBOY
Libérer: 2016-05-16 17:22:14
original
1112 Les gens l'ont consulté
复制代码 代码如下:



<script> <BR>function link(id) <BR>{ <BR>var obj = document.getElementById(id); <BR>var obj1 = document.getElementById('type2'); <BR>var name = ""; <BR>for(i = 0 ; i < obj.options.length ; i++ ) <BR>{ <BR>if(obj.options[i].selected) <BR>{ <BR>name = obj.options[i].value; <BR>} <BR>} <BR>var names = bargain_class.link(name).value.split(','); <BR>var obj1_count = obj1.options.length <BR>for (i = 0 ; i < obj1_count ; i++) <BR>{ <BR>obj1.options.remove(0); <BR>} <BR>for (i = 0 ; i < names.length ; i ++ ) <BR>{ <BR>option1 = document.createElement("option"); <BR>option1.innerHTML = names[i]; <BR>obj1.appendChild(option1); <BR>} <BR>// alert(names); <BR>} <BR></script>

//后台代码
AjaxPro.Utility.RegisterTypeForAjax(typeof(bargain_class)); //本页页面名

//===============================ajax调用=====================================
[AjaxPro.AjaxMethod]
public string link(string name)
{
string text = "";
string sql = "select name from Management_products_class where pid='" + name + "'";
DataTable dt = LinkSql.conn(sql);

for (int i = 0; i {
if (text == "")
{
text = dt.Rows[i]["name"].ToString();
}
else
{
text += "," + dt.Rows[i]["name"].ToString();
}
}
return text;
}
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!