Question

I don't even know if anybody will be able to help me with this, but basically I have an .asp page with some JQuery in it, that is supposed to do a window.location() on the current page with one URL parameter depending on the info the user wants to view. I have a button calling a function and here is the function as well.

<input type="submit" name="btnSearch" value="Search" onclick="ChangeSelection()" id="btnSearch" class="CommandButtonNoWidth" style="font-weight:bold;width:65px" />

function ChangeSelection(){
  var CaseType = $("#ddlType>option:selected").text();
  document.location = "AlertSearch.asp?CaseType=" + CaseType;
}

Basically that's all I want, set the CaseType in the URL and the page does the rest, but when I step through the entire code nowhere else are paramters being set, and this ends up being the URL in the window, caseType parameter nowhere to be found;

.../AlertSearch.asp?txtDateFrom=&txtDateTo=&ddlType=GTC+Expiring+Orders&ddlPlanid=All&ddlRecipient=Joe+Advisor&btnSearch=Search

the other parameters are the names of the other controls on the page, but there is no code anywhere that says to append these. Is this just the way a classic asp form works? Or am I missing something in code? I am not receiving any errors within my code and when debugging values look correct.

Was it helpful?

Solution

It might be because the input control has type of "submit" and is hence submitting the form that the other controls on the page are contained within. You could try changing the "type" attribute of the input tag to "button". This should stop the button click from submitting the form.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top