473,408 Members | 2,477 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,408 software developers and data experts.

in firefox the select with value null not work good

if I insert a string null in a select,
it change position; why?
I insert value "" in 2nd 3th select;

<style type="text/css">
td {border:2px solid pink;};
</style>

<table border="1">

<script type="text/javascript">

var dati1=new Array();
var dati2=new Array();
var dati3=new Array();
var dati4=new Array();
var counter=0;

function invia_dati()
{ //SELECT
var select1=document.form2.sel1 ;
var select2=document.form2.sel2 ;
var select3=document.form2.sel3 ;
var select4=document.form2.sel4 ;

dati1[counter]=[1];
dati2[counter]=[""];
dati3[counter]=[""];
dati4[counter]=[1];

var aa=0;
for (var i = 0; i <1; i++)
{select1.options[aa]=new Option( dati1[i],dati1[i]);
select2.options[aa]=new Option( dati2[i],dati2[i]);
select3.options[aa]=new Option( dati3[i],dati3[i]);
select4.options[aa]=new Option( dati4[i],dati4[i]);
aa++;}

counter++;
}

</script>

<tr>
<td colspan="4">
<br />
</td>
</tr>

<form method="post" name="form1" action="" >
<tr >
<td colspan="4">
<input type="button" name="bottons" value="CERCA"
onClick="invia_dati();"/>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
</form>
<form method="post" name="form2" action="" >
<tr>
<td>
<select name="sel1" size="20" style="width:100px" multiple></select>
</td>
<td>
<select name="sel2" size="20" style="width:100px"></select>
</td>
<td>
<select name="sel3" size="20" style="width:100px"></select>
</td>
<td>
<select name="sel4" size="20" style="width:100px"></select>
</td>
<td>
<select name="sel5a" size="20" style="width:100px"></select>
</td>
<td>
<select name="sel5b" size="20" style="width:100px"></select>
</td>
<td>
<select name="sel5c" size="20" style="width:100px"></select>
</td>
<td>
<select name="sel5d" size="20" style="width:100px"></select>
</td>

</tr>

</form>
</table>
Jun 20 '07 #1
2 2163
On Jun 20, 9:59 pm, artev <mailnotspa...@notspamm.nnwrote:
if I insert a string null in a select,
it change position; why?
I insert value "" in 2nd 3th select;
When posting code, please indent using 2 or 4 spaces and manually wrap
it at about 70 characters.
>
<style type="text/css">
td {border:2px solid pink;};
That final semi-colon is a syntax error in CSS.

</style>

<table border="1">

<script type="text/javascript">
It is always good to start with valid HTML. A script element can't be
a child of a table or tbody element in HTML 4.
>
var dati1=new Array();
var dati2=new Array();
var dati3=new Array();
var dati4=new Array();
var counter=0;

function invia_dati()
{ //SELECT
var select1=document.form2.sel1 ;
var select2=document.form2.sel2 ;
var select3=document.form2.sel3 ;
var select4=document.form2.sel4 ;
dati1[counter]=[1];
dati2[counter]=[""];
That makes the value an array of one element, whose value is an empty
string. It is not "null".
dati3[counter]=[""];
dati4[counter]=[1];

var aa=0;
for (var i = 0; i <1; i++)
{select1.options[aa]=new Option( dati1[i],dati1[i]);
select2.options[aa]=new Option( dati2[i],dati2[i]);
You are depending on the toString method of Array to return your
values, better to be more explicit:

{select1.options[aa]=new Option( dati1[i][0],dati1[i][0]);
select2.options[aa]=new Option( dati2[i][0],dati2[i][0]);

There doesn't seem much point to an array of one element, but maybe
you intend to put more values in there.

select3.options[aa]=new Option( dati3[i],dati3[i]);
select4.options[aa]=new Option( dati4[i],dati4[i]);
aa++;}

counter++;

}

</script>

<tr>
<td colspan="4">
<br />
</td>
</tr>

<form method="post" name="form1" action="" >
More invalid HTML: a form element can't be a child of a table or
tbody. A simple solution is to put the table inside the form.
<tr >
<td colspan="4">
<input type="button" name="bottons" value="CERCA"
onClick="invia_dati();"/>
</td>
</tr>
<tr>
</tr>
Yet more invalid HTML - a tr must have at least one td element inside
it.
<tr>
</tr>
</form>

<form method="post" name="form2" action="" >
....another form where it's not allowed...
<tr>
<td>
<select name="sel1" size="20" style="width:100px" multiple></select>
....and select elements must have at least one option...

Fixing your HTML plus simplifying and tidying the example will likely
fix your errors. If not, post what you end up with.
--
Rob

Jun 20 '07 #2
><select name="sel1" size="20" style="width:100px" multiple></select>
>
...and select elements must have at least one option...
Fixing your HTML plus simplifying and tidying the example will likely
fix your errors. If not, post what you end up with.
this is only a code for make a test; I have simplified one original
that is more complex and take datas from a db;

so it is only for make a test but is efficient for this scope;

the test is this:
first see the page html how is;

after change this
dati2[counter]=[""];
dati3[counter]=[""];
in this
dati2[counter]=[1];
dati3[counter]=[1];

and you can notice that the select are all ok how position;
make thet est with firefox and IE;

Jun 20 '07 #3

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

Similar topics

7
by: Jesper Stocholm | last post by:
I have som XML that link to an XSL-file to enable on-the-fly HTML-generation by e.g. IE or FireFox. The transformation actually works like a charm, but I have problems with changing line breaks in...
4
by: ioneabu | last post by:
I am trying to do the basic task of setting a text field from the choice made from a select box. I learned how to code it from my O'Reilly Javascript reference which is a few years old. The code...
3
by: Olivier Verdin | last post by:
Hi, I have a page with several Textboxes and several DropDownList. When I click on a 'save' button, it creates a record in a database. The page works fine under Internet Explorer. It does...
1
by: richardscheff | last post by:
Video selector works for IE but not other browsers. for not IE <object ID='Player' data="video/dodgeball.wmv" type="video/x-ms-wmv" width="320" height="280"> <param name="filename"...
3
by: palak123i | last post by:
Hi All, I am using a javascript to submit a request using AJAX. Part of javascript code as follows: var favElement = document.getElementById('fav1'); alert(favElement); for (var i = 0; i <...
11
by: davecph | last post by:
I'm constructing a website with a layout created with div-tags. They have a fixed width, float left, and display inline. When one of the div's contain a select-element the right-most div floats down...
5
by: Faizmysore | last post by:
This code works good in IE, function multiuser() { document.frmOpenInteraction1.Create.disabled=true; document.frmOpenInteraction1.hidmultiuser.value="Yes"; var r =...
1
by: rjdougan | last post by:
I am not a developer but need some help with scripts for a client. I have a script to handle form validation and one that handle mouseover on menu. The form validation script works fine by it...
3
by: SAL | last post by:
Hello, I did google this issue and found some stuff related to BrowserCaps section of either web.config or machine.config but it didn't work. It seems that most pages in my webapp are okay but a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
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...

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.