我的javascript出了什么问题 [英] What's wrong in my javascript

查看:79
本文介绍了我的javascript出了什么问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,



<前lang =cs>功能BtnSelect_Click_Complete(值){
var ofiledname;
// alert('aaa');
ofieldname = gup(< span class =code-string>' fieldname');
if (ofieldname!= null ){
// alert(ofieldname +:+ values [0] +:+ values [1]);
window.opener.SetLookup(opener.document,ofieldname,values [ 0 ],值[ 1 ] );
window.opener.PopulateParticipant(values [ 0 ],ofieldname);
}
self.close();
}





功能gup(名称)
{
var regexS = [\\?& ] + name + =([^&#] *);
var regex = new RegExp(regexS);
var tmpURL = window.location.href;
var results = regex.exec(tmpURL);
if (results == null
返回 ;
else
return 结果[ 1 ];
}





tmpURL获取:http:// localhost:59037 / ParticipantList

结果得到:



但结果应该是:'ComplainantID'或'RespondentID'



我完全陷入了困境。请帮帮我。

解决方案

你在URL字符串上应用正则表达式。这就是你想要的吗?



我的猜测是你希望你把它应用到url页面的包含。

在这种情况下你必须先下载页面,然后将regex应用到页面,而不是URL。 br />


对于问题的加载部分,看起来解决方案取决于您使用的库(JQuery)和数据格式(html,xml,text) 。



在任何情况下,至少在制作时,我建议以易于测试零件的方式拆分程序。

确保每个部分分开工作,当一切正常时,你可以自信地组合在一起。



w3schools.com是一个自学的好地方。


Hi Experts,

function BtnSelect_Click_Complete(values) {
            var ofiledname;
            //alert('aaa');
            ofieldname = gup('fieldname');
            if (ofieldname != null) {
                //alert(ofieldname + " : " + values[0] + " : " + values[1]);
                window.opener.SetLookup(opener.document, ofieldname, values[0], values[1]);
                window.opener.PopulateParticipant(values[0], ofieldname);
            }
            self.close();
        }



function gup( name )
{
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var tmpURL = window.location.href;
    var results = regex.exec( tmpURL );
    if( results == null )
        return "";
  else
    return results[1];
}



tmpURL is getting : http://localhost:59037/ParticipantList
results is getting : ""

But result should get : either 'ComplainantID' or 'RespondentID'

I am totally stuck at this point. Please help me.

解决方案

You apply the regex on URL string.Is it what you want ?

My guess is that you want you apply it to the contain of the page at url.
in this case you have to download the page first, and apply regex to the page, not the URL.

For the load part of the problem, it looks like the solution depend on which library you use (JQuery) and on the format of data (html, xml, text).

In any case, at least while making things, I recommend to split your program in a way that ease testing of parts.
Make sure each part works separately, when all works, you can put together confidently.

w3schools.com is a good place to go for self teaching.


这篇关于我的javascript出了什么问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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