Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wrong sort numbers being added

Status
Not open for further replies.

wilberforce2

IS-IT--Management
Jan 8, 2007
36
GB
I have some Javascript code that splits one string into categories for example:

Armed Forces[14]|Territorial Organisations and Bodies[1]

The categories are seperated by | and the numbers in the squate brackets are sort order.

The problem I am having is that the returning numbers submitted to the database search using asp are coming up wrong for example Armed forces returns Armed Forces[12] when the sort number should be 14? This only appears to happen on some of the categories. The code runs so it must be an error in the process somewhere.

To see what I mean the web page is located at:


I have sorted so that an SQL debug print appears on screen so you can see what is happening. If you prefer I can post the code here but there is quite a bit and did not want to flood the page with reams of code. The javascript code was written for me and although I have a basic understanding this problem is beyond what I understand so any help in what’s going wrong would be appreciated.

Many thanks.
 
what is the value of the select list when submitted, have you done a raw display to see if it is the JS messing up?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
The data is exported from the database and placed into an array called vsTableData which is on the search.asp page. I have checked the data from the array and it is correct.
 
That's not what I mean, when i choose the category, I take it the category and sort value is placed as the value section of the select list, so when the form is submitted , is the value of this sort order correct, if it is, then it would have to be the ASP code with the problem not the JS.





"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Thanks for your time.

If you select for example Armed forces and select search the JS writes the category value into a hidden field that is picked up via the ASP.

<input name="cbCategory" type="hidden" id="cbCategory" value="Armed Forces[12]">

Armed Forces should have a sort value of 14.

The confusing thing is that if you select Agriculture the damm thing works?
 
so the value being passed to the SQL is not correct, but the value assigned to the Array is correct.

so the onchange code is wrong somewhere!

wehre is the JS which holds buildCatList() function?





"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
if you place an alert here
Code:
	//Removes the sort number "[x]" from the value
	listValue = listValue.split("[")[0]

alert("listValue = "  + listValue[0] + " / " + listValue[1]);

what do you get?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I have added the alert and get the following message.

listValue = E / l

 
OIC not the dreaded Octal by default if zero in front syndrome! , glad you worked it out.

I'm still confused how you get this result though listValue = E / l

from the alert, when you change to armed forces it should say 'listValue = Armed Forces / [14]' oh well

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
side-note

The ms reference cited
refers to jscript version 3. And probably that's why the resolution is a bit awkward from the present point of view. The resolution should be providing the radix 10 for version 5 onward, as came across in a recent thread.
The info on jscript version and bundled ie version is here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top