Why javascript does not work on firefox?

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Sep 2006
Posts: 84
Reputation: rinoa04 is on a distinguished road 
Solved Threads: 4
rinoa04's Avatar
rinoa04 rinoa04 is offline Offline
Junior Poster in Training

Why javascript does not work on firefox?

 
0
  #1
Jul 25th, 2007
Hello, I have a doubt about javascript. When designing web based system, usually we used javascript to validate the form. It works fine in IE browser. However, all the validation does not work when tested on firefox browser.

Why and what is the problem? How to solve it so that the application can be used in any browser?

Thank you.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Why javascript does not work on firefox?

 
0
  #2
Jul 25th, 2007
You must be using browser specific features. IE is notorious in making your code run even when it is not correct. Paste the code and we will try to help you out. The only advice we can give you is to develop for Firefox so the possibility of the code working on other browsers is more plus you get a nice Error Console and tools like FireBug.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 84
Reputation: rinoa04 is on a distinguished road 
Solved Threads: 4
rinoa04's Avatar
rinoa04 rinoa04 is offline Offline
Junior Poster in Training

Re: Why javascript does not work on firefox?

 
0
  #3
Jul 26th, 2007
Here is part of the coding using C#. This is one of the module for ASP.NET web based system. Sorry if the coding are messy. The validation are mostly done using .NET validator in which is said to be javascript. Please correct me if I'm wrong.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. // Interface
  2. <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" Inherits="AddShippingRates" Src="AddShippingRates.cs"%>
  3. <%@ Register TagPrefix="uc1" TagName="InnovaBanner" Src="InnovaBanner.ascx" %>
  4. <%@ Register TagPrefix="uc1" TagName="AdminLinks" Src="AdminLinks.ascx" %>
  5. <%@ Register TagPrefix="uc1" TagName="copyrightfooter" Src="copyrightfooter.ascx" %>
  6. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<a rel="nofollow" class="t" href="http://www.w3.org/TR/html4/loose.dtd" target="_blank">http://www.w3.org/TR/html4/loose.dtd</a>">
  7. <html>
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  10. <title>InnovaCraft-AddShippingRates</title>
  11. <link href="StyleAdmin.css" type=text/css rel=stylesheet>
  12. </head>
  13. <body>
  14. <table width="806" height="589" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#993333">
  15. <tr>
  16. <td width="817" height="16" bgcolor="#993333">&nbsp;</td>
  17. </tr>
  18. <tr>
  19. <td height="16" bgcolor="#993333" align="center"><uc1:InnovaBanner id="InnovaBanner1" runat="server"></uc1:InnovaBanner></td>
  20. </tr>
  21. <tr>
  22. <td height="16" bgcolor="#FFFFFF"><uc1:AdminLinks id="AdminLink1" runat="server"></uc1:AdminLinks></td>
  23. </tr>
  24. <tr>
  25. <td height="16" bgcolor="#993333"><span class="adminManagementTitle">Add Shipping Rates </span></td>
  26. </tr>
  27. <tr>
  28. <td height="16" bgcolor="#FFFFFF"><span class="welcome">Welcome&nbsp;&nbsp;&nbsp;
  29. <asp:Label ID="admin" runat="server" /> </span></td>
  30. </tr>
  31. <tr>
  32. <td height="600" valign="top" bgcolor="#FFFFFF"><form name="form1" method="post" runat="server">
  33. <table width="800" border="0" cellspacing="0" cellpadding="0">
  34. <tr>
  35. <td valign="top"><table width="792" border="0" align="left" cellpadding="0" cellspacing="0">
  36. <tr>
  37. <td colspan="6"><asp:Label ID="Message" Visible="false" runat="server" CssClass="adminContent"/></td>
  38. </tr>
  39. <tr>
  40. <td width="146"><span class="adminContent">Shipping Rate ID</span></td>
  41. <td colspan="5"><asp:TextBox ID="sidtxt" runat="server" Columns="5" ReadOnly="true" TextMode="SingleLine" /></td>
  42. </tr>
  43. <tr>
  44. <td><span class="adminContent">Country</span></td>
  45. <td colspan="5"><asp:TextBox ID="countrytxt" runat="server" TextMode="SingleLine" /></td>
  46. </tr>
  47. <tr>
  48. <td><span class="adminContent">Shipping Rate </span></td>
  49. <td colspan="5"><asp:TextBox ID="ratetxt" runat="server" TextMode="SingleLine" /></td>
  50. </tr>
  51. <tr>
  52. <td colspan="6">&nbsp;</td>
  53. </tr>
  54. <tr>
  55. <td>&nbsp;</td>
  56. <td colspan="2">&nbsp;</td>
  57. <td width="78"><asp:Button ID="add" Text="Add" Width="60" runat="server" /></td>
  58. <td width="77"><asp:Button ID="reset" Text="Reset" runat="server" Width="60" CausesValidation="false" /></td>
  59. <td width="250"><asp:Button ID="cancel" Text="Cancel" runat="server" CausesValidation="false" /></td>
  60. </tr>
  61. <tr>
  62. <td colspan="6">&nbsp;</td>
  63. </tr>
  64. </table>
  65. <p>&nbsp;</p>
  66. <p>&nbsp;</p>
  67. <p>&nbsp;</p>
  68. <p>&nbsp;</p>
  69. </td>
  70. </tr>
  71. <tr>
  72. <td><table width="793" border="0" align="left" cellspacing="0">
  73. <tr>
  74. <td colspan="2"><asp:DataGrid AllowPaging="true" DataKeyField="ShippingRateID" ID="Shippingdg" runat="server" AutoGenerateColumns="false" OnPageIndexChanged="Paging" PageSize="5" Width="800" AlternatingItemStyle-CssClass="alternateRow">
  75. <columns>
  76. <asp:BoundColumn DataField="ShippingRateID" HeaderText="Shipping Rate ID" ReadOnly="true">
  77. <headerstyle CssClass="dgheaderStyle"></headerstyle>
  78. <itemstyle CssClass="dgitemStyle"></itemstyle>
  79. </asp:BoundColumn>
  80. <asp:BoundColumn DataField="DeliveryCountry" HeaderText="Country Destination">
  81. <headerstyle CssClass="dgheaderStyle"></headerstyle>
  82. <itemstyle CssClass="dgitemStyle"></itemstyle>
  83. </asp:BoundColumn>
  84. <asp:BoundColumn DataField="ShippingRates" HeaderText="Shipping Rates(USD)">
  85. <headerstyle CssClass="dgheaderStyle"></headerstyle>
  86. <itemstyle CssClass="dgitemStyle"></itemstyle>
  87. </asp:BoundColumn>
  88. <asp:TemplateColumn HeaderText="Edit">
  89. <headerstyle CssClass="dgheaderStyle"></headerstyle>
  90. <itemstyle CssClass="dgitemStyle"></itemstyle>
  91. <itemtemplate>
  92. <asp:HyperLink runat="server" Width="20" NavigateUrl='<%# "EditShippingRates.aspx?Shipping_ID=" + DataBinder.Eval(Container.DataItem, "ShippingRateID") %>' >Edit</asp:HyperLink>
  93. </itemtemplate>
  94. </asp:TemplateColumn>
  95. <asp:TemplateColumn HeaderText="Delete">
  96. <headerstyle CssClass="dgheaderStyle"></headerstyle>
  97. <itemstyle CssClass="dgitemStyle"></itemstyle>
  98. <itemtemplate>
  99. <asp:CheckBox ID="delcb" runat="server"></asp:CheckBox>
  100. </itemtemplate>
  101. </asp:TemplateColumn>
  102. </columns>
  103. <pagerstyle HorizontalAlign="Right" Mode="NumericPages" CssClass="dgFooter"></pagerstyle>
  104. </asp:DataGrid></td>
  105. </tr>
  106. <tr>
  107. <td height="26" colspan="2">&nbsp;</td>
  108. </tr>
  109. <tr>
  110. <td>&nbsp;</td>
  111. <td><asp:Button ID="delete" Text="Delete Checked Item(s)" runat="server" CausesValidation="false" /></td>
  112. </tr>
  113. <tr>
  114. <td colspan="2">&nbsp;</td>
  115. </tr>
  116. <tr>
  117. <td><asp:RequiredFieldValidator ControlToValidate="countrytxt" Display="None" ErrorMessage="Country must not be empty" ID="empty1" runat="server" />
  118. <asp:RequiredFieldValidator ControlToValidate="ratetxt" Display="None" ErrorMessage="Shipping Rates must not be empty" ID="empty2" runat="server" />
  119. <asp:RegularExpressionValidator ControlToValidate="countrytxt" Display="None" ErrorMessage="Country must be alphabets" ID="v1" runat="server" ValidationExpression="[a-zA-Z]*" />
  120. <asp:RegularExpressionValidator ControlToValidate="ratetxt" Display="None" ErrorMessage="Rate must be in price format" ID="v2" runat="server" ValidationExpression="[0-9][0-9]*(\.+\d{2})?" />
  121. &nbsp;</td>
  122. <td>&nbsp;</td>
  123. </tr>
  124. <tr>
  125. <td width="639"><asp:ValidationSummary DisplayMode="BulletList" HeaderText="ERROR:" ID="summary" runat="server" ShowMessageBox="true" ShowSummary="false"/>
  126. &nbsp;</td>
  127. <td width="150">&nbsp;</td>
  128. </tr>
  129. </table>
  130. <p>&nbsp;</p>
  131. <p>&nbsp;</p>
  132. <p>&nbsp;</p>
  133. <p>&nbsp;</p>
  134. <p>&nbsp;</p>
  135. <p>&nbsp;</p>
  136. <p>&nbsp;</p>
  137. <p>&nbsp;</p>
  138. <p></p></td>
  139. </tr>
  140. </table>
  141. </form>
  142. </td>
  143. </tr>
  144. <tr>
  145. <td height="16" bgcolor="#FFFFFF"><uc1:copyrightfooter id="Copyrightfooter1" runat="server"></uc1:copyrightfooter></td>
  146. </tr>
  147. </table>
  148. </body>
  149. </html>
  150.  
  151. // Coding for the logic
  152. using System;
  153. using System.Web.UI;
  154. using System.Web.UI.WebControls;
  155. using System.Data;
  156. using System.Data.SqlClient;
  157. using System.Configuration;
  158. using System.Web;
  159. public class AddShippingRates : Page
  160. {
  161. protected Label Message;
  162. protected Button add;
  163. protected DataGrid Shippingdg;
  164. protected TextBox sidtxt;
  165. protected TextBox ratetxt;
  166. protected TextBox countrytxt;
  167. protected Button reset;
  168. protected Button cancel;
  169. protected Button delete;
  170. protected Label admin;
  171. SqlConnection con;
  172. string db = ConfigurationSettings.AppSettings["constring"].ToString();
  173. #region Web Form Designer generated code
  174. override protected void OnInit(EventArgs e)
  175. {
  176. //
  177. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  178. //
  179. InitializeComponent();
  180. base.OnInit(e);
  181. }
  182.  
  183. /// <summary>
  184. /// Required method for Designer support - do not modify
  185. /// the contents of this method with the code editor.
  186. /// </summary>
  187. private void InitializeComponent()
  188. {
  189. this.delete.Click += new System.EventHandler(this.Delete_Click);
  190. this.reset.Click += new System.EventHandler(this.Reset_Click);
  191. this.add.Click += new System.EventHandler(this.Add_Click);
  192. this.cancel.Click += new System.EventHandler(this.Cancel_Click);
  193. }
  194. #endregion
  195. private void Page_Load(object sender, System.EventArgs e)
  196. {
  197. // Disable caching in user's web browser works both in IE and Firefox
  198. Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
  199. Response.Cache.SetCacheability(HttpCacheability.NoCache);
  200. Response.Cache.SetNoStore();
  201. // Disallowed user to browse the page when not login
  202. if ( Session["adminuser"] == null )
  203. {
  204. Response.Redirect("index.aspx");
  205. }
  206. admin.Text = Session["adminuser"].ToString();
  207. Message.Text = "";
  208. delete.Attributes.Add("OnClick", "return confirm('Are you sure to delete the item?');");
  209. try
  210. {
  211. con = new SqlConnection(db);
  212.  
  213. getID();
  214. if ( !IsPostBack )
  215. {
  216. BindGrid();
  217. }
  218. }
  219. catch ( Exception ex )
  220. {
  221. Message.Text = "<b>ERROR: " + ex.Message;
  222. Message.Style["color"] = "red";
  223. Message.Visible = true;
  224. }
  225. }
  226. // Datagrid Binding
  227. private void BindGrid()
  228. {
  229. SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM ShippingRates ORDER BY ShippingRateID DESC", con);
  230. DataSet ds = new DataSet();
  231. sda.Fill(ds, "ShippingRates");
  232. Shippingdg.DataSource=ds.Tables["ShippingRates"].DefaultView;
  233. Shippingdg.DataBind();
  234. }
  235. // Paging on datagrid
  236. public void Paging(object sender, DataGridPageChangedEventArgs e)
  237. {
  238. Shippingdg.CurrentPageIndex = e.NewPageIndex;
  239. Shippingdg.DataBind();
  240. BindGrid();
  241. }
  242. // Get next Shipping ID
  243. private void getID()
  244. {
  245. SqlCommand maxId = new SqlCommand("SELECT MAX(ShippingRateID) FROM ShippingRates", con);
  246. con.Open();
  247.  
  248. string result = maxId.ExecuteScalar().ToString();
  249. int id = Convert.ToInt32(maxId.ExecuteScalar().ToString());
  250. int getId = 1;
  251.  
  252. if ( !result.Equals("") || !result.Equals("Null") )
  253. {
  254. getId = id + 1;
  255. }
  256. con.Close();
  257.  
  258. sidtxt.Text = getId.ToString();
  259. }
  260. // Add data to database
  261. public void Add_Click(object sender, EventArgs e)
  262. {
  263. int sid = Convert.ToInt32(sidtxt.Text);
  264. double rates = Convert.ToDouble(ratetxt.Text);
  265. string country = countrytxt.Text;
  266.  
  267. try
  268. {
  269. string exist = "SELECT COUNT(*) FROM ShippingRates WHERE DeliveryCountry = '"+country+"'";
  270. SqlCommand query = new SqlCommand(exist, con);
  271. con.Open();
  272.  
  273. int yes = Convert.ToInt32(query.ExecuteScalar().ToString());
  274. if ( yes > 0 )
  275. {
  276. Message.Text = "<b>Error: " + country + " already exist in the database<br>";
  277. Message.Style["color"] = "red";
  278. Message.Visible = true;
  279. }
  280. else
  281. {
  282. string insertQuery = "INSERT INTO ShippingRates VALUES ("+sid+", "+rates+", '"+country+"')";
  283. SqlCommand SqlCom = new SqlCommand(insertQuery, con);
  284. SqlCom.ExecuteNonQuery();
  285. Message.Text = "<b>Record has been Added<br>";
  286. Message.Style["color"] = "red";
  287. Message.Visible = true;
  288. }
  289. }
  290. catch ( SqlException )
  291. {
  292. Message.Text = "<b>ERROR: Problem with query";
  293. Message.Style["color"] = "red";
  294. Message.Visible = true;
  295. }
  296. con.Close();
  297. getID();
  298. ratetxt.Text = "";
  299. countrytxt.Text = "";
  300. BindGrid();
  301. }
  302. // Delete checked items
  303. private void Delete_Click(object sender, System.EventArgs e)
  304. {
  305. DataGridItem dgItem;
  306. CheckBox chkItem = new CheckBox();
  307. Shippingdg.CurrentPageIndex = 0;
  308.  
  309. for ( int i = 0; i < Shippingdg.Items.Count; i++ )
  310. {
  311. dgItem = Shippingdg.Items[i];
  312. chkItem = (CheckBox)dgItem.FindControl("delcb");
  313.  
  314. if ( chkItem.Checked == true )
  315. {
  316. int key = Convert.ToInt32(Shippingdg.DataKeys[dgItem.ItemIndex]);
  317. string deleteQuery = "DELETE FROM ShippingRates WHERE ShippingRateID = "+key+"";
  318. SqlCommand SqlCom = new SqlCommand(deleteQuery, con);
  319. SqlCom.Parameters.Add(new SqlParameter("@sid", SqlDbType.Int, 20));
  320. SqlCom.Parameters["@sid"].Value = Shippingdg.DataKeys[dgItem.ItemIndex];
  321. SqlCom.Connection.Open();
  322. try
  323. {
  324. SqlCom.ExecuteNonQuery();
  325. Message.Text = "<b>Record has been deleted</b><br>";
  326. Message.Style["color"] = "red";
  327. Message.Visible = true;
  328. }
  329. catch (SqlException)
  330. {
  331. Message.Text = "<b>ERROR: Could not delete record</b>";
  332. Message.Style["color"] = "red";
  333. Message.Visible = true;
  334. }
  335. SqlCom.Connection.Close();
  336. }
  337. }
  338. getID();
  339. BindGrid();
  340. }
  341. // Reset the form
  342. private void Reset_Click(object sender, System.EventArgs e)
  343. {
  344. countrytxt.Text = "";
  345. ratetxt.Text = "";
  346. }
  347. // Back to shipping rates main page
  348. private void Cancel_Click(object sender, System.EventArgs e)
  349. {
  350. Response.Redirect("ManageShippingRates.aspx");
  351. }
  352. }
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Why javascript does not work on firefox?

 
0
  #4
Jul 26th, 2007
First of all, considering that this is not a C# forum, the ones who try to solve your query might not necessarily have .NET to try out your code. Secondly, you need to give exact error messages which appear in the Firefox error console and paste the relevant code removing the C# mess if you plan on getting help from this 'Javascript' forum. Either that or repost in the C# forums.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 84
Reputation: rinoa04 is on a distinguished road 
Solved Threads: 4
rinoa04's Avatar
rinoa04 rinoa04 is offline Offline
Junior Poster in Training

Re: Why javascript does not work on firefox?

 
0
  #5
Jul 26th, 2007
I am very sorry if I cause any confusion. There is no error return when running the system using firefox browser. The only problem is validation using javascript is not working in firefox in which means that user can submit the form by entering any values and the values submitted are stored in the database.

If anyone ever encounter this kind of problem when developing web based system using javascript for client side validation using any language, please advice if you know why.

I have heard that coding for browser detection need to be added to solve the problem. Please correct me if I am wrong.

Thank you very much
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Why javascript does not work on firefox?

 
0
  #6
Jul 27th, 2007
The best way to get help would be to remove the C# code from the code above and post just HTML and Javascript so that testing it would be easy.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Why javascript does not work on firefox?

 
0
  #7
Aug 5th, 2007
Did you also take into account what would happen if JavaScript is turned off in the browser security section?
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1
Reputation: dragy is an unknown quantity at this point 
Solved Threads: 0
dragy dragy is offline Offline
Newbie Poster

Re: Why javascript does not work on firefox?

 
0
  #8
Sep 7th, 2007
Hi all,
I have similar problem. App works fine on IE, but FireFox doesn't fire javascript function. When I put checkbox on checked, row should change the color. This is my javascript code:
...
<head runat="server">
<title>Unos dužnika</title>
<LINK href="StyleSheet.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
//declare global variables
function chkSelect_OnClick(tableRowId,
checkBox, rowIndex)
{
var bgColor;
bgColor = "#ebeaef";
if(checkBox.checked == true)
tableRowId.style.backgroundColor = "#ffffff";
else
tableRowId.style.backgroundColor = bgColor;

}
</script>
</head>
...

Could you tell me what is the problem?
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 60
Reputation: kaushik259106 is an unknown quantity at this point 
Solved Threads: 0
kaushik259106 kaushik259106 is offline Offline
Junior Poster in Training

Re: Why javascript does not work on firefox?

 
0
  #9
Sep 8th, 2007
use the inbuild error console in firefox to know your error..its cool..
tool -> error console

first clear the console and then execute ur web app in firefox and continiously check for any error message in the error console
Last edited by kaushik259106; Sep 8th, 2007 at 1:13 am.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Why javascript does not work on firefox?

 
0
  #10
Sep 9th, 2007
Originally Posted by dragy View Post
Hi all,
I have similar problem. App works fine on IE, but FireFox doesn't fire javascript function. When I put checkbox on checked, row should change the color. This is my javascript code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. ...
  2. <head runat="server">
  3. <title>Unos dužnika</title>
  4. <LINK href="StyleSheet.css" type="text/css" rel="stylesheet">
  5. <script type="text/javascript">
  6. //declare global variables
  7. function chkSelect_OnClick(tableRowId,
  8. checkBox, rowIndex)
  9. {
  10. var bgColor;
  11. bgColor = "#ebeaef";
  12. if(checkBox.checked == true)
  13. tableRowId.style.backgroundColor = "#ffffff";
  14. else
  15. tableRowId.style.backgroundColor = bgColor;
  16.  
  17. }
  18. </script>
  19. </head>
  20. ...

Could you tell me what is the problem?
- I don't see you CALLING your code. You are loading the code, but not executing it. Maybe your strange syntax is an IE proprietary extension.

- You spelled onclick wrong (it's case sensitive), and placed it in the wrong place. onclick goes in the html tag you want to click on, not in the JavaScript code.

For instance, to call your function chkSelect when the mouse clicks on a certain div or on a certain paragraph, do this:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html .... >
  2. <head>
  3. ....
  4. <script type="type/javascript">
  5. ....
  6. function chkSelect(){
  7. ....
  8. }
  9. ....
  10. </script>
  11. ....
  12. </head>
  13. <body>
  14. ....
  15. <div onclick="javascript:chkSelect()">
  16. ....
  17. </div>
  18. ....
  19. <p onclick="javascript:chkSelect()">
  20. ....
  21. </p>
  22. ....
  23. </body>
  24. </html>

Almost any tag can contain an onclick attribute.
Last edited by MidiMagic; Sep 9th, 2007 at 9:18 pm.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC