Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 8th, 2005, 06:34 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default wierd error

Code:
<script>
// Sort Array (02-08-2005)
// by Vic Phillips http://www.vicsjavascripts.org.uk

function zxcSelectSort(zxcid,zxcfirstoption)
{
// zxcid - 'city'
// zxcfirstoption - '1' 


 zxcobj=document.getElementById(zxcid);
 zxcAry=new Array();
 for (zxc0=zxcfirstoption;zxc0<zxcobj.options.length;zxc0++)
 {
  zxcAry[zxc0-zxcfirstoption]=zxcobj.options[zxc0];
 }
 zxcAry=zxcAry.sort(zxcOptionSort);
 for (zxc1=0;zxc1<zxcAry.length;zxc1++)
 {
  zxcobj.options[zxc1+zxcfirstoption]=new Option(zxcAry[zxc1].text,zxcAry[zxc1].value,true,true);

  document.form.text.value=zxcAry[zxc1].text;
  document.form.zxcobj.value=zxcobj;
 }
}

function zxcOptionSort(zxca,zxcb)
{

 zxcA=zxca.text.toLowerCase();
 zxcB=zxcb.text.toLowerCase();
 document.form.test.value = zxca.text
 document.form.test2.value = zxcb.text
 if (zxcA<zxcB)
 {
     return -1;
 }
 if (zxcA>zxcB)
 { 
     return 1;
 }
 return 0;
}



</script>

<body bgcolor="#f5f5f5" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" onload="zxcSelectSort('city',1);">
<form name="form" id="form" method="post" action="destination4.asp">
<select name="city" id="city" style="font-size:9px" onChange="form.submit()">
<option value="empty"> </option>
<%
do until rscitycode.eof
set rsnotrains = con.execute("select DISTINCT Airportcode,CityCode from dbo_tp_airport where Citycode = '"& rscitycode("CityCode") &"' and Facilitycode = 'A'")
do until rsnotrains.eof 

set rsnozug = con.execute("select DISTINCT CityName from dbo_tp_cityname where CityCode = '" & rsnotrains("CityCode") & "'")
do until rsnozug.eof
%>

<% if rsnozug("CityName") <> temp then %>
<option><%=rsnozug("CityName")%></option>
<%
end if
temp = rsnozug("CityName")
rsnozug.movenext
loop
rsnotrains.movenext
loop
rscitycode.movenext
loop
%>
</select>
</form>
I am having a wierd problem with this script.

When i INCLUDE the line:
Code:
document.form.zxcobj.value=zxcobj;
i get a 'null or not an object' error, but everything is passed to the next page and it works ok.

But when i take it out i get NO ERROR, but the following page (destination4.asp) doesnt work.

The 'city' form field is knocked out??



www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old August 8th, 2005, 10:50 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Crmpicco!!

zxcobj=document.getElementById(zxcid); //It returns an object

document.form.zxcobj.value=zxcobj; //You Can't assign an object to value type

You can use
zxcobj.options[zxc0].Text
zxcobj.options[zxc0].Value

Again there is no form element in the form with name "zxcobj"
you need to eval function so that u can get right object then assign it's text/value to the required text/value

I think the below line will always give u an error
document.form.text.value=zxcAry[zxc1].text;

since there is no form element with "text" as name

use eval function to get required object ,then assign object value /text property to the value/text

Hope this will help you

Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd Printing Problem danielr Infopath 2 February 6th, 2007 05:54 AM
Wierd XSLT behavior roygabv XSLT 1 September 29th, 2006 11:24 AM
Wierd Linking problems with Xcode 2.3 scratt Xcode 0 June 8th, 2006 07:37 AM
PlaySound makes wierd noise darthziv C# 2 April 5th, 2006 02:52 AM
Wierd Date Calculations Steven Access 2 December 16th, 2003 07:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.