Solved

Remote event handler calling (why doesn't it work in NS??!)

Posted on 2001-08-09
22
293 Views
Last Modified: 2012-06-27
Why doesn't this work in Netscape?

<HTML>
<BODY>
<form name="form">
<input value="click" type=button onclick="document.form.text1.click()">
<input value="change" type=button onclick="document.form.text1.onchange()">

<input type=text name="text1" onclick="document.form.text1.value = 'clicked'" onchange="document.form.text1.value = 'changed'">
</form>

<P>&nbsp;</P>

</BODY>
</HTML>


This very simple code should populate the text box when either button is clicked.

Works perfectly fine in IE5.. but NS6..  not at all.

Why?

How can I get this to work?
0
Comment
Question by:d_jedi
  • 8
  • 6
  • 3
  • +3
22 Comments
 
LVL 4

Expert Comment

by:DMN
ID: 6369661
I can't check it write now but try to write document.forms[0] insted of document.form
0
 

Author Comment

by:d_jedi
ID: 6369681
BTW:  the code is just a sample.. not what I actually intend to do with it.

The reason for it is, I have a date function that allows the user to choose a date from a calendar, which is placed into a textbox.

No event is fired when the textbox changes as a result of this.  But I need to be able to execute code when the date changes.

I therefore, inserted code to call the onchange event handler of the textbox when the user chooses a date.

I have other options available, but these are much less preferable.
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 6369688
don't name your form "form", as this is a javascript keyword.  try "myform" instead:

<form name="form">
<input value="click" type=button onclick="document.myform.text1.click()">

0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 33

Expert Comment

by:knightEknight
ID: 6369690
oops:

<form name="myform">
0
 

Author Comment

by:d_jedi
ID: 6369692
DMN:

this does not work.  
0
 

Author Comment

by:d_jedi
ID: 6369704
knightEknight:

this does not work.

form is not a javascript keyword, BTW
0
 

Author Comment

by:d_jedi
ID: 6369709
knightEknight:

this does not work.

form is not a javascript keyword, BTW
0
 
LVL 2

Expert Comment

by:allie
ID: 6369750
d_jedi,

Fourth line down in the code you gave, you have
"document.form.text1.click()".  I changed that to
"document.form.text1.onclick()" and it worked in Netscape.  It worked either way in IE for some reason though...

allie
0
 

Author Comment

by:d_jedi
ID: 6370020
allie:

doesn't work in NS6 either way..

I'm actually more concerned with the onChange event, FYI
0
 
LVL 1

Expert Comment

by:Y_ee
ID: 6370173
Hey I just tested in ns4 ie 5 and ns 6 everything is working like this:

<HTML>
<BODY>
<form name="form">
<input value="click" type="button" onclick="document.form.text1.onclick()">
<input value="change" type="button" onclick="document.form.text1.onchange()">
<input type=text name="text1" onclick="document.form.text1.value='clicked'" onchange="document.form.text1.value='changed'">
</form>
</BODY>
</HTML>

all I did is change click() to onclick() like allie said

ciao
Y
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 6370301
cool! points for allie.

but "form" is a javascript keyword in the sense that it is a property of the form objects -- refering to the parent form, like this:

   <INPUT type='text' onFocus='alert(this.form.name);'>

or this:

   <INPUT type='button' value='Submit' onClick='this.form.submit();'>
0
 
LVL 2

Accepted Solution

by:
allie earned 50 total points
ID: 6372517
d_jedi,

Couple 'o things:
First, did you notice that if you click in the TEXT box first, then click either of the buttons (at least with my change) it DOES work in Netscape 6?  (Weird, huh?)  However, knowing that, I took the script out and put it in script tags, and this DOES work in Net6:

<HTML>
<BODY>
<script language="JavaScript"><!--
function fChange(){
   document.myForm.text1.value = 'changed';
}
function fClick(){
   document.myForm.text1.value = 'clicked';
}
-->
</script>
<form name="myForm">
<input value="click" type=button onclick="fClick()">
<input value="change" type=button onclick="fChange()">
<input type=text name="text1" onclick="fClick()" onchange="fChange()">
</form>
<P>&nbsp;</P>
</BODY>
</HTML>

Second, what particular version are you using?  Because Netscape has some sort of "pre-release" version out there - it's not fully debugged, and I wouldn't recommend using it.  If you go to Help on the browser it'll tell you not only the version number, but also if it's the pre-release version.

Anyway, hope this helps!  Good luck...

allie
0
 

Author Comment

by:d_jedi
ID: 6373334
Allie:

Indeed, when you first click on the textbox, then the code does work.. but this does not solve my problem (read my first comment about why I need this code).

I thought that maybe if I set focus to the textbox first, then Netscape would work...  but it doesn't.

Putting the code into a function as you have in your last comment is not what I'm looking for.

Y ee:
Changing to onclick does not work..  except after clicking in the textbox first.
0
 
LVL 2

Expert Comment

by:allie
ID: 6373566
d_jedi-

Why is putting code into a function not what you're looking for?  At least from what I can see, it doesn't make any difference if the code is in-line or a function call - you execute the code when onchange of the textbox is called either way.  Maybe if you post your real code we could get a better idea what you're looking for?

allie
0
 

Author Comment

by:d_jedi
ID: 6373911
allie:

because the date function is called from many different pages.. and every function call that I would wish to make would require me to modify the date function.

I guess that workaround is possible.. but very much less preferable..

I would only consider that option if Netscape can't do what I want it to

(I HATE Netscape!!  Henceforth called 'Netsucks' by my development team.. for various reasons :->)
0
 
LVL 2

Expert Comment

by:allie
ID: 6384189
d_jedi,

Sorry, I don't see any way around it - at least if it has to be compatible with Netscape 6.  And you have my COMPLETE sypathy on trying to code for both IE and Netsucks (*Grin*  I like that one...), as well as for all the versions.  I've been working on a page for 6 months that we've just discovered has problems in N6 (although it works perfectly in N4!).  Stupid browser...

allie
0
 

Author Comment

by:d_jedi
ID: 6385620
Perhaps I could use a function.. with the same name on every page..  only prob. is, then I'd have to insert an empty function where I have the date function and no 'onchange' code to execute..

unless...

how does Javascript handle overloaded functions? (or does it, even)
0
 
LVL 2

Expert Comment

by:allie
ID: 6385667
I don't think it handles them well - and I'd certainly be nervous trying that for a cross-browser designed web page.  However, if there's one thing you want to happen always, and one only sometimes, you could just add a switch in your parameters like this:

function myFunction(bDoCode)
{
...do Code for all
if( bDoCode )
   ...do Code for some
}

allie
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6918332
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> You cannot delete a question with comments, special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20121834.html
http://www.experts-exchange.com/questions/Q.20155547.html
http://www.experts-exchange.com/questions/Q.20155541.html
http://www.experts-exchange.com/questions/Q.20166098.html
http://www.experts-exchange.com/questions/Q.20172358.html
http://www.experts-exchange.com/questions/Q.20173609.html
http://www.experts-exchange.com/questions/Q.20242805.html
http://www.experts-exchange.com/questions/Q.20273496.html




PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7084643
Zero response, finalized by Moondancer - EE Moderator
0
 
LVL 2

Expert Comment

by:allie
ID: 7088400
Thanks Moondancer!  'Preciate it.

allie
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7090989
Thank you for your help. :)
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question