Click to See Complete Forum and Search --> : 'Null' is null... When using ASP generated JS onChange location.href Dropdown List
Eulibrius7
04-26-2004, 09:21 PM
I have a dropdown list that will "refine" the records shown based on a criterion. The feature works fine with straight Javascript however when generated by ASP it gives the 'null' is null or not an object yet it still WORKS! The ASP generated code looks exactly the same as the pure Javascript code so I don't see what the issue could be.
URL: http://doxism.com/pics.asp?type_id=Cars
ASP Code:
With Response
.Write "<div id=""filter_select"" align=""center"">" & vbNewline
.Write "<div class=""navtext"">Refine List:</div>" & vbNewline
.Write "<select name=""select"" size=""1"" onChange = ""location.href = 'pics.asp?type_id="&strTypeID&"&name_id="&strNameID&"&filter_id='+this.value"">" & vbNewline
.Write "<option value=""""></option>" & vbNewline
.Write "<option value=""[a-z]"">A-Z</option>" & vbNewline
.Write "<option value=""[a-g]"">A-G</option>" & vbNewline
.Write "<option value=""[h-l]"">H-L</option>" & vbNewline
.Write "<option value=""[m-q]"">M-Q</option>" & vbNewline
.Write "<option value=""[r-z]"">R-Z</option>" & vbNewline
.Write "</select>" & vbNewline
.Write "</div>" & vbNewline
End With
PeOfEo
04-26-2004, 09:25 PM
where is this error if it all still works... is it a js error or server error, post a ss or copy the message.
Eulibrius7
04-26-2004, 09:30 PM
Check out the URL and try to use the Refine Drop Down List. It is a client-side JS error...Thanks.
PeOfEo
04-26-2004, 09:36 PM
Originally posted by Eulibrius7
Check out the URL and try to use the Refine Drop Down List. It is a client-side JS error...Thanks. nope. None for me. Ill look in internet explorer, but I browser on mozilla and did not see one. Ok, I see what you mean in ie. The error message says 'null". Why are you using javascript to control this list since it is going to another page anyway, one way to solve the whole issue about javascript not being supported by 13% of the internet (according to last year's stats on the counter) would be to drop js for this and do it server side. Also how you are writing out the js might be causing you some organisational problems and might be to blame.
Try something more like
<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
dim str1
str1= "hihi"
%>
<div onmouseover="style.borderColor='#000000';" onmouseout="style.borderColor='#cccccc';" style="border:1px solid #cccccc">
<% response.Write(str1) %>
</div>
<%
'more code would go here
%>
</body>
</html>
I just made a lil example with that, you know you are out of it when you start typeing java instead of vbscript
(System.out.println instead of response.write :p)
Eulibrius7
04-26-2004, 09:51 PM
I don't know what it is with people throwing out random statistics like you that turns me green with envy ;). But anyway, how would I begin approaching this server-side? I code hands-on (by-example) and not from the ground up since I haven't the time to dedicate to mastering any programming languages.. The logic I have but am somewhat lacking in syntax & object knowledge...lol. Thanks for your help... and I am truly envious of your vast 'guru-like' knowledge!
PeOfEo
04-26-2004, 10:22 PM
Useless statistic? http://www.thecounter.com/stats/2003/May/javas.php
When a user goes to your site and does not support javascript nothing will happen when they try to use that menu, that is why javascript should be kept to aesthetics and not functional code like navigation, and if it is used to power a drop down menu or something make it so that if the user does not have js the whole thing is displayed or provide a backup nav alltogether. That is good etiquette. But to do that drop down menu server side you are going to use an asp form action in there and when you resend the value have a script ge the form value with request.form(key), well let me make an example
<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
dim selection
selection = request.Form("select")
if selection = "" then
response.write("please select a value")
else
response.write("Your selection:" & selection & "<br>You can format a url and reditect to a page using query string too<hr>" _
& "Response.redirect("/yourpage.asp?selection=" & selection & ") <br>" _
& "turns in to: /yourpage.asp?selection=" & selection)
end if
%>
<form action="/script.asp" method="post">
<select name="select" size="1">
<option value=""></option>
<option value="[a-z]">A-Z</option>
<option value="[a-g]">A-G</option>
<option value="[h-l]">H-L</option>
<option value="[m-q]">M-Q</option>
<option value="[r-z]">R-Z</option>
</select>
<input type="submit" value="Submit" />
</form>
</body>
</html>
I could not figure out how to get it to resend with the change of the option, but heck I use asp.net not asp so i have an excuse. http://quasi-ke.servebeer.com/back.asp is the page if you want to see this in action. I just loved your sarcasm in your last post btw.
Eulibrius7
04-26-2004, 11:58 PM
Correct me if I'm retarded... I'm using DWMX as a web development tool and before rebuilding the site I opted for ASP.NET technology but ran into a dead end when I began integrating db-driven features and .NET only supported SQL or some backend db software that wasn't [ahem] free. I'm running an IIS server on WinXP Pro with Access DBs configured through the OBDC as a sytem DSN. The domain name points to NO-IP DNS servers which dynamically point to the IP address on my cable connexion. If you have any tips for fine-tuning my setup or programming techniques (I use the term loosely) I would jump up and down with joy and click my heels like a tap dancin' elf! Anyway, thanks... I willl begin working on this server-side solution, I opted for js before because of the onChange event handler otherwise I wouldn't have opted for any client-side scripting at all since I'm piss poor at it!
PeOfEo
04-27-2004, 05:12 AM
I use xp pro, have iis5, use dreamweaver for design, also use no-ip for dns, but I prefer to use mssql server... pretty similar. But only host this server for local testing mainly. Asp.net though has event aware controls, so using the asp.net
<asp:dropdownlist AutoPostBack="true" runat="server" ID="mylist" OnSelectedIndexChanged="sub_mylistddlchange"></asp:dropdownlist>
will fire that sub when you change that value.