473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

why can't recognize index in hidden variable

Hi

I got a question in a form. that's:

<TABLE WIDTH="100%" BORDER=0><TD align="Left" width="19%" >
<select name="DEPARTMENT" SIZE ="1" style="width:200px;"
onChange="Change()">
<option value="0"> &lt;ALL&gt
<option value="1000012" >Food Sales
....
</select>
</TD>

<FORM name="InputForm" id="InputForm" method="post" action="url">
<INPUT TYPE="HIDDEN" NAME="DEPARTMENT" VALUE="">

function Change()
{
var selIndex = document.InputForm.DEPARTMENT.selectedIndex;
alert("****" + selIndex + "***");
var selValue =
document.InputForm.DEPARTMENT.options[selIndex].value;
the question is, why the pop up message always says ***undefined***
whenever a change to the selection?

It should indentify the selected index, right?

Can any one point it out?

--
Thanks lots
John
Toronto

Jul 23 '05 #1
4 1394
"john woo" <jo******@canada.com> skrev i meddelandet
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi

I got a question in a form. that's:

<TABLE WIDTH="100%" BORDER=0><TD align="Left" width="19%" >
<select name="DEPARTMENT" SIZE ="1" style="width:200px;"
onChange="Change()">
<option value="0"> &lt;ALL&gt
<option value="1000012" >Food Sales
...
</select>
</TD>

<FORM name="InputForm" id="InputForm" method="post" action="url">
<INPUT TYPE="HIDDEN" NAME="DEPARTMENT" VALUE="">

function Change()
{
var selIndex = document.InputForm.DEPARTMENT.selectedIndex;
alert("****" + selIndex + "***");
var selValue =
document.InputForm.DEPARTMENT.options[selIndex].value;
the question is, why the pop up message always says ***undefined***
whenever a change to the selection?

It should indentify the selected index, right?


No, it shouldn't. A hidden field has no selected index. And the hidden field
of the form "InputForm" is what your code accesses.

--
Joakim Braun
Jul 23 '05 #2
Thanks lots.

one more question, if the form in above code is included from others,
how can I overwrite the accessiblity of the variable in that form?

--
Best Regards

John

Jul 23 '05 #3
john woo wrote:
[..]
<select name="DEPARTMENT" SIZE ="1" style="width:200px;"
onChange="Change()">
<option value="0"> &lt;ALL&gt
<option value="1000012" >Food Sales
...
</select>
</TD>

<FORM name="InputForm" id="InputForm" method="post" action="url">
<INPUT TYPE="HIDDEN" NAME="DEPARTMENT" VALUE="">

function Change()
{
var selIndex = document.InputForm.DEPARTMENT.selectedIndex;
alert("****" + selIndex + "***");
var selValue =
document.InputForm.DEPARTMENT.options[selIndex].value;
the question is, why the pop up message always says ***undefined***
whenever a change to the selection?

It should indentify the selected index, right?

Can any one point it out?


Your select object appears to be outside of your form, and your hidden
field object should have a unique name.

Mick
Jul 23 '05 #4

Not sure I get you on the accessibility part and var deal.
Danny

On Sun, 03 Jul 2005 09:58:34 -0700, john woo <jo******@canada.com> wrote:
Thanks lots.

one more question, if the form in above code is included from others,
how can I overwrite the accessiblity of the variable in that form?

--
Best Regards

John


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: deko | last post by:
Is there any way to work around the blank space created by hidden divs? I'm trying to use a relatively postioned divs with show/hide behaviors to annotate an image. The divs show/hide...
3
by: aaa | last post by:
I am unable to get a my popup to recognize a hidden field on the calling page. I have this working on a different page although that page is a tad simpler. The page I am trying now calls from a...
15
by: TC | last post by:
What does it mean for an integer to have a null value? I am trying to use the DataView.Find method. That method has an integer return type which contains the "index of the row in the DataView...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
1
by: pbd22 | last post by:
hi. i have been posting this here and elsewhere a lot and can't seem to get resolution on this problem. i have been trying to upload files using a hidden iframe to a asp.net/vb.net form. the...
2
by: everly | last post by:
Hi, I'm helping my friends band and making their MySpace. I messed something up and I can't figure out what it is. Everything is all out of whack on the bottom half of the page. The comments...
10
anfetienne
by: anfetienne | last post by:
i take information from a database and then have the collected values entered into a form with hidden fields. <input type="hidden" name="tempID" id="tempID" value='<?php print...
1
anfetienne
by: anfetienne | last post by:
i take information from a database and then have the collected values entered into a form with hidden fields. <input type="hidden" name="returnURL" id="returnURL" value="<?php print...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.