the old JS question: IE vs Firefox

B

Bruno Alexandre

Hi guys,

I'm performing a form validation using the javascript in the ASPX pages and
I got into a part that I can't figure it out how to move foward.

All is resumed in this page:

http://filterqueen.brinkster.net/new_fastcash.dk/users/test.aspx

the pages works like:
on DropDown change I pick up it's value and show it in the textbox
on Button click I add new numbers dynamically to the dropdown

1st Question:
Why does the onChange Dropdown work on IE and not in Firefox? (it's
simple Javascript!)
2nd Question:
Why can I grab the dropdown values having then from start, and then
when I add it dynamically I couldn't do it anymore?


so How can I have both questions working fine?

Thank you for all the help.
 
V

ValliM

Hi Bruno,

You can make the below changes in script, to get your condition work.

function show()
{

var index=document.getElementById("ddAvis").selectedIndex;

document.getElementById("txtAvis").value =
document.getElementById("ddAvis").options[index].innerHTML;

}

function addOptions()

{

document.getElementById("txtAvis").value=" ";

var aa = new Array();

aa[0] = '';

aa[1] = '11';

aa[2] = '12';

aa[3] = '13';

aa[4] = '14';

for ( i=0; i<aa.length; i++ )

{

var myNewOption=new Option(aa,' ');

document.getElementById("ddAvis").options=myNewOption;

}

}

Apply this changes and let me know if you have any doubts.

Regards,

Valli

(www.syncfusion.com)

ASP.Net FAQ:
http://www.syncfusion.com/faq/aspnet/default.aspx

Complete set of ASP.Net controls and components
http://www.syncfusion.com/toolsweb
 
W

Washington Moreira

Hi Bruno,
When you recreate the options on your select element, each value is left in
blank. Your javascript redefines the innerText only for each Option like
this:

<select name="ddAvis" id="ddAvis" onchange="show();" >
<option value=""></option>
<option value="">11</option>
<option value="">12</option>
<option value="">13</option>
<option value="">14</option>
</select>

So, if you change your function to:

function show() {
document.getElementById('txtAvis').value =
document.activeElement.children[document.activeElement.selectedIndex].innerText;
//alert(document.getElementById('ddavis').value);
}

Then it will work!!
cheers

Washington Moreira
(From Brazil)
 
B

Bruno Alexandre

thank you very much :)

I joined both example and so the final line is:

document.getElementById("ddAvis").options[document.getElementById("ddAvis").selectedIndex].innerText;

Thank you both once again :)

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)


Washington Moreira said:
Hi Bruno,
When you recreate the options on your select element, each value is left
in blank. Your javascript redefines the innerText only for each Option
like this:

<select name="ddAvis" id="ddAvis" onchange="show();" >
<option value=""></option>
<option value="">11</option>
<option value="">12</option>
<option value="">13</option>
<option value="">14</option>
</select>

So, if you change your function to:

function show() {
document.getElementById('txtAvis').value =
document.activeElement.children[document.activeElement.selectedIndex].innerText;
//alert(document.getElementById('ddavis').value);
}

Then it will work!!
cheers

Washington Moreira
(From Brazil)

Bruno Alexandre said:
Hi guys,

I'm performing a form validation using the javascript in the ASPX pages
and I got into a part that I can't figure it out how to move foward.

All is resumed in this page:

http://filterqueen.brinkster.net/new_fastcash.dk/users/test.aspx

the pages works like:
on DropDown change I pick up it's value and show it in the textbox
on Button click I add new numbers dynamically to the dropdown

1st Question:
Why does the onChange Dropdown work on IE and not in Firefox?
(it's simple Javascript!)
2nd Question:
Why can I grab the dropdown values having then from start, and
then when I add it dynamically I couldn't do it anymore?


so How can I have both questions working fine?

Thank you for all the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top