Hi there,
I'm trying to get this working with Firefox. Can you point out what's
wrong? No problems with IE, Firefox doens't fill selMonth...
TIA the script... >>>
<select name="selDay" id="selDay" style="width:50 ;" ></select> -
<select name="selMonth" id="selMonth" style="width:50 ;"></select> -
<select name="selYear" id="selYear" style="width:75 ;"></select>
<script language="JavaS cript">
function initDateSelect( ) {
for (x=1; x<32; x++) {
document.getEle mentById('selDa y').options[x-1] = new Option(x,x); }
for (x=1; x<13; x++) {
document.getEle mentById('selMo nth').options[x] = new Option(x,x); }
for (x=1920; x<2020; x++) {
document.getEle mentById('selYe ar').options[x-1920] = new Option(x,x); }
}
initDateSelect( );
</script> 6 3033
The problem might be that you're starting at 1 instead of 0. I've never
tried making .options a sparse array, so not sure how well it would
handle that.
Try
for (x=0; x<12; x++) {
I generally prefer something more like:
mySelectElement .add( new Option( strText, strValue ) );
----
Thought I'd also note that it's usually easier on the user to give them
a box to put the number in and then JS validate that number.
Sjaakie wrote: Hi there, I'm trying to get this working with Firefox. Can you point out what's
wrong? No problems with IE, Firefox doens't fill selMonth...
TIA
>>> the script... >>> <select name="selDay" id="selDay" style="width:50 ;" ></select> - <select name="selMonth" id="selMonth" style="width:50 ;"></select> - <select name="selYear" id="selYear" style="width:75 ;"></select>
<script language="JavaS cript">
function initDateSelect( ) { for (x=1; x<32; x++) { document.getEle mentById('selDa y').options[x-1] = new Option(x,x); } for (x=1; x<13; x++) { document.getEle mentById('selMo nth').options[x] = new Option(x,x); } for (x=1920; x<2020; x++) { document.getEle mentById('selYe ar').options[x-1920] = new Option(x,x);
} }
initDateSelect( ); </script>
Random wrote: The problem might be that you're starting at 1 instead of 0. I've never tried making .options a sparse array, so not sure how well it would handle that.
Try for (x=0; x<12; x++) {
No effect...
I generally prefer something more like:
mySelectElement .add( new Option( strText, strValue ) );
I tried
document.getEle mentById("selDa y").add( new Option( "test","tes t" ) );
no effect at all.
Firefox seems to act very differently compared to IE.
for( x = 1; x < 13; x++ )
document.getEle mentById( 'selMonth' ).options[ x - 1 ] =
new Option( x, x );
Worked fine for me. FF apparently doesn't like making sparse arrays out
of .options lists, and I don't blame it.
Start at 0 for indices in .options.
My mistake on .add(), by the way. That's IE-only, so couldn't possibly
have fixed your problem.
Literally, here is the code I used:
<html><body><fo rm>
<select name="selDay" id="selDay" style="width:50 ;" ></select> -
<select name="selMonth" id="selMonth" style="width:50 ;"></select> -
<select name="selYear" id="selYear" style="width:75 ;"></select>
<script language="JavaS cript">
function initDateSelect( ) {
for( x = 1; x < 32; x++ )
document.getEle mentById( 'selDay' ).options[ x - 1 ] =
new Option( x, x );
for( x = 1; x < 13; x++ )
document.getEle mentById( 'selMonth' ).options[ x - 1 ] =
new Option( x, x );
for( x = 1920; x < 2020; x++ )
document.getEle mentById( 'selYear' ).options[ x - 1920 ] =
new Option( x, x );
}
initDateSelect( );
</script>
</form></body></html>
Sjaakie wrote: Random wrote: The problem might be that you're starting at 1 instead of 0. I've
never tried making .options a sparse array, so not sure how well it would handle that.
Try for (x=0; x<12; x++) {
No effect...
I generally prefer something more like:
mySelectElement .add( new Option( strText, strValue ) );
I tried document.getEle mentById("selDa y").add( new Option( "test","tes t" ) ); no effect at all.
Firefox seems to act very differently compared to IE.
This indeed did the trick, FF doesn't allow non-0-based option lists.
Thanks for your help.
Random wrote: for( x = 1; x < 13; x++ ) document.getEle mentById( 'selMonth' ).options[ x - 1 ] = new Option( x, x );
Worked fine for me. FF apparently doesn't like making sparse arrays out of .options lists, and I don't blame it.
Start at 0 for indices in .options.
My mistake on .add(), by the way. That's IE-only, so couldn't possibly have fixed your problem.
Literally, here is the code I used: <html><body><fo rm>
<select name="selDay" id="selDay" style="width:50 ;" ></select> - <select name="selMonth" id="selMonth" style="width:50 ;"></select> - <select name="selYear" id="selYear" style="width:75 ;"></select>
<script language="JavaS cript">
function initDateSelect( ) { for( x = 1; x < 32; x++ ) document.getEle mentById( 'selDay' ).options[ x - 1 ] = new Option( x, x );
for( x = 1; x < 13; x++ ) document.getEle mentById( 'selMonth' ).options[ x - 1 ] = new Option( x, x );
for( x = 1920; x < 2020; x++ ) document.getEle mentById( 'selYear' ).options[ x - 1920 ] = new Option( x, x );
}
initDateSelect( );
</script> </form></body></html> Sjaakie wrote:
Random wrote:
The problem might be that you're starting at 1 instead of 0. I've never tried making .options a sparse array, so not sure how well it would handle that.
Try for (x=0; x<12; x++) {
No effect... I generally prefer something more like:
mySelectElem ent.add( new Option( strText, strValue ) );
I tried document.getE lementById("sel Day").add( new Option( "test","tes t" ) ); no effect at all.
Firefox seems to act very differently compared to IE.
On 23/05/2005 12:15, Random wrote:
[snip] My mistake on .add(), by the way. That's IE-only, so couldn't possibly have fixed your problem.
No it isn't. The add method is defined by the W3C, but Microsoft have an
entirely incompatible implementation. The only way to use it reliably[1]
is to use a try/catch statement, but that will cause problems if a user
agent implements the add method, but not an exception mechanism.
[snip]
<select [...] style="width:50 ;">
With CSS, all non-zero length values must be accompanied by a unit
specifier.
[snip]
<script language="JavaS cript">
The language attribute is deprecated. Use the (required) type attribute
instead:
<script type="text/javascript">
function initDateSelect( ) { for( x = 1; x < 32; x++ )
If a variable has no business being global, ensure you declare it local.
function initDateSelect( ) {
var x;
/* ... */
}
[snip]
Mike
[1] I've experimented with other way that infers the expected
arguments based on the length property of the method, but
that may not be reliable.
Please don't use tabs when posting code. Use spaces - preferably two -
when indenting instead.
You've been instructed on how to post properly though Google Groups.
Please do so.
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Sjaakie wrote: Hi there, I'm trying to get this working with Firefox. Can you point out what's wrong? No problems with IE, Firefox doens't fill selMonth...
TIA
>>> the script... >>> <select name="selDay" id="selDay" style="width:50 ;" ></select> - <select name="selMonth" id="selMonth" style="width:50 ;"></select> - <select name="selYear" id="selYear" style="width:75 ;"></select>
<script language="JavaS cript">
function initDateSelect( ) { for (x=1; x<32; x++) { document.getEle mentById('selDa y').options[x-1] = new Option(x,x); }
Repeatedly using getElementById is likely slow, use a local variable
to hold a reference to the options and add to that.
for (x=1; x<13; x++) { document.getEle mentById('selMo nth').options[x] = new Option(x,x); }
Your first month option will be index 1, that seems to cause Firefox
to not display the options:
document.getEle mentById('selMo nth').options[x-1] = new Option(x,x);
for (x=1920; x<2020; x++) { document.getEle mentById('selYe ar').options[x-1920] = new Option(x,x); } }
initDateSelect( ); </script>
Here's another version that may run a bit faster and avoids
getElementById by using the forms collection (and therefore should
have wider browser support):
<form name="dForm" action="">
<select name="selDay" style="width: 3em;"></select> -
<select name="selMonth" style="width: 3em;"></select> -
<select name="selYear" style="width: 5em;"></select>
</form>
<script type="text/javascript">
var x = 0;
var opt = document.dForm. selDay.options;
while ( x++ < 31 ) { opt[x-1] = new Option(x,x); }
x = 0;
opt = document.dForm. selMonth.option s;
while ( x++ < 12 ) { opt[x-1] = new Option(x,x); }
x = 0;
opt = document.dForm. selYear.options ;
while ( x++ < 100 ) { opt[x-1] = new Option(x+1919,x +1919); }
</script>
Using 'em' as the unit for width means the size of the options will
scale to whatever font size the user's browser is set to. Using
script-generated form elements may cause accessibility issues for
some users and those without JavaScript will not see any options.
--
Rob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jon |
last post by:
Hi all,
I am trying to dynamically fill an array with any unique values from a field
(objRS.Fields(5)) in my database with the following code below. However it
errors with "The array is fixed or temporarily blocked" for the line "REDIM
PRESERVE UserArray(Arraycount+1)". I can't seem to get around this. Any
suggestions? Many thanks.
Dim p
Dim UserArray(0) ' Max number of users
|
by: J. Muenchbourg |
last post by:
I have 3 select pulldown boxes where a user will select a year (either
2002 or 2001), a week (one thru 52), and a database (short data or long
data). But if a user selects a week that is less than 4, the 3rd select
pulldown will only show the choice of "short data", as they will not be
able to select "long data". Is it dynamically possible in javascript to
program a third pull down in this fashion?
thx
Muench
|
by: lkrubner |
last post by:
I'm facing an extremely irksome bug in FireFox. This select tag is not
rendering quite right. When I click on it to choose a color, it shows a
scroll tab, but the scroll only goes down to the 43 option and ends
with f0f. However, I find that when I use the arrow keys, I can still
walk through the whole list. It just isn't visible. Considering the
javascript involved, this is a limiting bug.
Text color: <select...
|
by: crjunk |
last post by:
I have a 3 table in my DataSet that I'm filling with data. After I've
filled these 3 tables, I'm then trying to run a query that will fill a
4th table in the DataSet with data from the three tables that are
already pouplated.
When my code tries to fill the 4th table, ReportData, I receive the
following error message: Invalid object name 'tmpPROJECTINFO'. Invalid
object name 'tmpContacts'. Invalid object name 'tmpRECEIVEREC'.
Can...
|
by: tshad |
last post by:
I have a couple of stored procedures that are being called from my Page_Load
event.
They worked before, but now they are not working.
I am getting the error:
Specified argument was out of the range of valid values. Parameter name:
value
| |
by: BJ |
last post by:
Hi,
I add label and text box fields dynamically in code using C# and ASP.NET. I
set the width of the label using:
Label label = new Label();
label.Width = 20;
label.Text = "Test";
panel.Controls.Add(label);
|
by: joseph.lindley |
last post by:
Forgive me for I am a bit of a web-dev novice - but I'm not doing too
bad.
I'm currently working with a bit of javascript to dynamically add
<option>s into a select box. My code currently works fine in Internet
Explorer, however in Firefox the dropdown only displays the first
option in the list, and when clicked the other values aren't displayed.
Here is the code;
|
by: Hoss |
last post by:
Hello all-
This is what im trying to achieve. At the top of my page there is some
search functionality, through which you cause to be loaded a string
representing an HTML page. Below this and occuupying about 80% of the
window real estate, there is a DIV. There is also a toggle button with
two options "Code View" and "Text View" as I have named them. Depending
on which mode you are in, you can see the block of HTML either as code
(in...
|
by: cbjewelz |
last post by:
Hey all.
So I'm having problems with cross browser alignments. I'm looking at Safari and Mozilla Firefox. I develop in Safari and so it looks perfect there however in Firefox my vertical alignments and div widths are off. It's as if firefox has a different definition of a pixel than safari. Here is the url: http://theprize.chemouni.com/testing.php. When you select the Option from the pull down, the first part of the form appears. Then when...
|
by: Patrick Nolan |
last post by:
I am using javascript to manipulate optgroups in select elements.
When the results are displayed in Firefox 2.0 there is an
annoying blank line at the top of the multi-line select box.
This doesn't happen with IE7.
There's a little program below which illustrates the problem.
I create two multi-line select boxes. The first one has an
optgroup and an option specified in the HTML. That one displays
with "opt1" as the first line. The...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |