hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : onChange with 2 values not working in FireFox
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

onChange with 2 values not working in FireFox

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-09-2005, 12:15 PM
TalkEgypt TalkEgypt is offline
Disabled
 
Join Date: Jul 2005
Posts: 2

onChange with 2 values not working in FireFox


Hello,

I'm trying to do an onchange in the dropdown options but unfortunately it only works in IE and not in firefox, how is it possible to make it work in firefox?

Part of Code:

Code:
<form method="post" action="*****.php">
<SELECT NAME='country' class='inputbox' onChange="areacode.value=this[this.selectedIndex].value2">

         <OPTION value2="" VALUE=''>---- Select here ----</OPTION>

             <option value2="93" value="1" >Afghanistan</option>
<option value2="355" value="2" >Albania</option>
<option value2="213" value="3" >Algeria</option>

<option value2="684" value="4" >American Samoa</option>
<option value2="376" value="5" >Andorra</option>
<option value2="244" value="6" >Angola</option>
<option value2="1264" value="7" >Anguilla</option>
<option value2="672" value="8" >Antarctica</option>
<option value2="1268" value="9" >Antigua And Barbuda</option>
<option value2="54" value="10" >Argentina</option>
<option value2="374" value="11" >Armenia</option>
<option value2="297" value="12" >Aruba</option>
         </SELECT>

<input type="text" size="2" name="areacode" DISABLED>
</form>
I need the value2 to be entered in the textbox and not necessary to be submitted to the form, but the value should be submitted, when I try this code on Firefox on each select I get undefined, but it works on IE. So what's the solution for firefox. Please help

Regards,

Reply With Quote


Sponsored Links
  #2  
Old 07-09-2005, 01:11 PM
FierceRecon FierceRecon is offline
Newbie
 
Join Date: Jul 2005
Posts: 7
document.getElementById('areacode'). instead of just areacode.

and add id="areacode" in the tag

i'm pretty sure that'll work

Reply With Quote
  #3  
Old 07-09-2005, 01:49 PM
VolkNet VolkNet is offline
Web Hosting Master
 
Join Date: Jun 2004
Location: Bay Area -USA
Posts: 1,738
hehe I had this same problem my friend.

Here was my solution:
PHP Code:
<script language="JavaScript">
function 
updatew3(){
    
selecteditem document.forms[0].areacode.selectedIndex ;
    
selval document.forms[0].areacode.optionsselecteditem ].value ;
    
document.forms[0].value2.value selval;
}
</script> 
Code:
<form method="post" action="*****.php">
<SELECT NAME='country' class='inputbox' onChange="updatew3()">
 <OPTION name='value2' VALUE=''>---- Select here ----</OPTION>
Hope that works

__________________
<<< Please see Forum Guidelines for signature setup. >>>

Reply With Quote
Sponsored Links
  #4  
Old 07-09-2005, 02:07 PM
TalkEgypt TalkEgypt is offline
Disabled
 
Join Date: Jul 2005
Posts: 2
Thanks for your reply, But actually it didn't work.

I got this error upon selecting an option:
document.forms.0.areacode.options is null or not an object.

Waiting for your reply.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Mozilla Firefox 23 Will Block Mix SSL Content by Default Web Hosting News 2013-04-12 11:39:07
Mozilla Updates CA Certificate Policy for Software Products Web Hosting News 2013-02-19 12:32:22
Mega Firefox Extension Speeds Up Downloads, Removes File Size Limits Web Hosting News 2013-02-11 11:43:22
Web Host ServInt Encourages Community Work with Customer Charity Award Web Hosting News 2012-03-08 11:12:54
Dutch Telecommunications Firm KPN Stops Issuing SSL Certificates After Hack Detected Web Hosting News 2011-11-07 15:29:02


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?