• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what's wrong with this script

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello friends,
please let me know what's wrong with this script.
<SCRIPT LANGUAGE = "JavaScript">
<!--
var browsername = navigator.appName;
if (browsername == "Netscape")
{
browsername = "navigator";
<INPUT TYPE="submit" name="press">
alert('you are using' + browsername);
}
else if (browsername == "Microsoft Internet Explorer")
{
browsername= "msie";
<INPUT TYPE="submit" name = "click">
alert('you are using' + browsername);
}
//-->
</SCRIPT>
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are mixing javascript with HTML. You can't have HTML code directly written in your javascript code. So it is the <input> tags in your javascript that is causing the main error.
What you want is to have the javascript in your head, and then have the form below. When someone clicks on the button, run the function in your javascript.
Bill
 
pranavi pendyala
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks bill. But i have one more doubt. what i am trying to do here is
when you give <INPUT TYPE=file name =file> that will give you a textbox to directly type in the file name and a browse button right. Here i want to disable the textbox part so, that the user can only use the browse button.
For that i tried using <INPUT TYPE= file NAME=file READONLY=true>.This piece of line only works in IE but in netscape i can still type into the textbox.
I really need your help here. This is kind of urgent for me.
Please help me.
Thanks a lot in advance.
Pranavi p.
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Netscape doesn't support READONLY as you have just seen. You can simulate it with have an onblur() method called when the input box gets focus.
So you can say this:

Bill
 
pranavi pendyala
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bill,
I tried that too. But it wouldn't work either. I am using netscape 6.
Is there any thing else i can do.
Please let me know.
thanks
pranavi p.
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Haven't done much testing on Netscape 6 yet. Can't help there. Netscape 6 is still so new and not many users have it yet, so I am still going with Netscape 4.0 and up (but not to 6.0 yet) and IE 4.0 and up.
Bill
 
pranavi pendyala
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks bill.
Pranavi P.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pranavi,
Can you try using javascript to do this...
Try something like this..
On focus of the texbox call a javascript function to set the focus to browse button, thereby making textbox1 as disabled.Try if this works out...
 
My cellmate was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic