开发者

include javascript query parameters in URL?

I am currently working on downloading the data automatically on this page:

http://jcmramp.pjm.com/jcmRamp/ramp-data.jsp

I would like to somehow be able to control the URL so that, say, when I use the URL:

jcmramp.pjm.com/jcmRamp/ramp-data.jsp?directionSlt=1

the option selected for Location parameter would be PJM and when I do

jcmramp.pjm.com/jcmRamp/ramp-data.jsp?directionSlt=2

the option selected for Location parameter would be MISO

Here is the relevant section in the HTML code I can see:

 <td colspan="4" align="top">
   <label id="selectLbl" for="directionSlt" unselectable="on">Location:</label>&nbsp;&nbsp;&nbsp;&nbsp;
   <select name="directionSlt" id="directionSlt" size="1" onchange="refresh()">
     <option value="1">PJM
     <option value="2">MISO
    </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <开发者_开发问答label class="linkLabel" id="helpLbl" onmouseover="this.style.color='orange'" onmouseout="this.style.color='navy'" onclick="javascript:openHelpPage();"> - README (ramp viewer description document)</label>&nbsp;&nbsp;&nbsp;&nbsp;
   <br><br>
 </td>

However, this does not seem to work, no matter what I put for directionSlt, I get PJM, which is the default selection.

I am just wondering if there is any other way possible to manipulate the URL to change the option.

If not, is it possible for me to programatically (using VB.Net) to switch between different option?

(Note: the HTTP sign for the second and third URLs are removed as per website's restrictions)


try this:

(function ($) {

    $.locationSearch = function () {
        var resultado = [];
        try {
            var search = window.location.search;
            if (search == null || search == '')
                return [];

            search = search.replace(/\?/, '').split('&');
            for (var i in search)
                resultado[search[i].split('=')[0]] = search[i].split('=')[1];
        }
        catch (ex) {}

        return resultado;
    };

})(jQuery);

$(function() {

   var query = $.locationSearch();

   if (typeof query['directionSlt'] != 'undefined') {
     $('#directionSlt').val(query['directionSlt']);
   }

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜