JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 11th, 2003, 04:36 AM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 6
Show/hide text and select/unselect Radiobuttons

I have put together some Javascript's that shall Show/hide some text and a textbox, and Select/unselect some Radiobuttons with different names. It works in IE and NS, but not in Opera. (Some of the script are a rewritten MX Javascript).

Question: Does anybody know how to make it work in Opera?

The code:
PHP Code:
<head>
<
script language="JavaScript">
function 
optionValue() { //v6.0
  
var i,p,v,obj,args=optionValue.arguments;
  for (
i=0i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (
obj.style) { obj=obj.stylev=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    
obj.visibility=v; }
}
</script></head>

<input name="KundePrivat" type="radio" value="true" checked onclick="KundeBedrift.checked=false;optionValue('MVA','','h  ide','MVA1','','hide')">
<input type="radio" name="KundeBedrift" value="true" onclick="KundePrivat.checked=false;optionValue('MVA','','sh  ow','MVA1','','show')">

<div id="MVA">Foretaksnummer:*</div>
<div id="MVA1"><input name="KundeMvaNr" type="text" id="KundeMvaNr"></div> 

Reply With Quote
  #2  
Old August 15th, 2003, 10:43 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
EiSa,

Just out of curiosity, try using the "display" property rather than "visibility".

Also, you may want to look into manipulating the DOM, which would ensure cross-browser compatability.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old August 18th, 2003, 04:35 PM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 6
Could you please explain this a little bit more, I'm not the best person in JS, or perhaps you know a resource that I could look into?

Reply With Quote
  #4  
Old August 18th, 2003, 09:08 PM
digitalamit digitalamit is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: New Delhi, India
Posts: 19 digitalamit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to digitalamit Send a message via AIM to digitalamit Send a message via Yahoo to digitalamit
I think it may help ....

Instead of using ...
Code:
MM_findObj(args[i])

try
Code:
document.getElementById(args[i])


HTH!

Reply With Quote
  #5  
Old August 20th, 2003, 12:12 PM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 6
Didn't help either. In Opera the

onclick="KundePrivat. checked=false and onclick="KundePrivat. checked=false doesn't work either.

But thank's for trying.

Reply With Quote
  #6  
Old August 20th, 2003, 07:10 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Not sure if you have done this for brievity, but when referring to form elements (or anything else for that matter), you should always use its full DOM reference. (note that you can normally leave of the 'window')

So, for your radio button called KundePrivat, you would refer to it as follows:
Code:
document.frmName.KundePrivat.checked = false
OR
document.forms[FormIndexPos].KundePrivat.checked = false
As browsers are becoming more strict (read: compliant), coders have to properly follow the DOM structure.

Also don't put a space after your dots. e.g. "object. checked"

Reply With Quote
  #7  
Old August 21st, 2003, 01:21 AM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 6
Thank's stumpy, your suggestion made it work.

By the way, the space thing wasn't in my code, it was something this forum made with my code. It has happened before also when posting something about Javascript.

Reply With Quote
  #8  
Old August 21st, 2003, 01:30 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Kewl - yeah, Opera is one of the more stricter browsers around, so it's good to develop on such a platform.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Show/hide text and select/unselect Radiobuttons


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway