473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

document.getElementById('form:b2').click(); Not working in Mozilla

58
Hi all,

I am trying to click a button using javascript code as follows

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('form:b2').click(); 
The above mentioned code working properly in IE but not working in Mozilla.

Is thr any other alternative javascript code inorder to click a button???

Thanks&Regards,
sundar.
Aug 30 '07 #1
8 34545
dmjpro
2,476 2GB
Hi all,

I am trying to click a button using javascript code as follows

* document.getElementById('form:b2').click();
The above mentioned code working properly in IE but not working in Mozilla.

Is thr any other alternative javascript code inorder to click a button???

Thanks&Regards,
sundar.

Will you post your HTML code.
Then it ll be better to solve your problem.

Kind regards,
Dmjpro.
Aug 30 '07 #2
gits
5,390 Expert Mod 4TB
hi ...

the typical way is as follows:

[HTML]<script type="text/javascript">
function do_the_click(btn) {
alert('you clicked the button with id = ' + btn.id);
}
</script>

<input type="button" value="click me" id="clk_btn" onclick="do_the_click(this);"/>[/HTML]

kind regards
Aug 30 '07 #3
acoder
16,027 Expert Mod 8TB
Are you sure "form:b2" is the id and not the name?
Aug 30 '07 #4
gsuns82
58
Are you sure "form:b2" is the id and not the name?
Alternative script method for the following:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('formID:fieldId').click();
  2.  
Thanks&Regards,
sundar
Aug 30 '07 #5
gsuns82
58
hi ...

the typical way is as follows:

[HTML]<script type="text/javascript">
function do_the_click(btn) {
alert('you clicked the button with id = ' + btn.id);
}
</script>

<input type="button" value="click me" id="clk_btn" onclick="do_the_click(this);"/>[/HTML]

kind regards

Alternative script method for the following:

document.getElementById('formID:fieldId').click();

Thanks&Regards,
sundar
Aug 30 '07 #6
acoder
16,027 Expert Mod 8TB
Alternative script method for the following:

document.getElementById('formID:fieldId').click();
Are you giving the solution or asking a question?

Show the generated HTML, not the JSP. View source on the browser and post the HTML/Javascript.
Aug 30 '07 #7
pbmods
5,821 Expert 4TB
Sundar, please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Aug 30 '07 #8
hi ...

the typical way is as follows:

[HTML]<script type="text/javascript">
function do_the_click(btn) {
alert('you clicked the button with id = ' + btn.id);
}
</script>

<input type="button" value="click me" id="clk_btn" onclick="do_the_click(this);"/>[/HTML]
Try this:

[HTML]document.getElementById('clk_btn').click();[/HTML]

clk_btn is the ID of your button, if the id is unique in the document that will work. IE and Mozilla have different ways of handling ID serches in the DOM tree thats why it worked on IE. IE creates all the DOM structure into the JS object hierarchy, which means that you can locate this button (assuming its inside a FORM called f1) using something like this...

Expand|Select|Wrap|Line Numbers
  1. document.f1.clk_btn
However, that's not a JavaScript standard (acording to W3C). Unlike IE, Mozilla is a http://www.w3c.org standard compliant browser (sort of), so that will not work in Mozilla.
Apr 3 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Chris | last post by:
Heres my problem: <a href="javascript:void(document.buysell.submit())" target="_parent" onMouseOver="MM_swapImage('members','','images/membersf2.gif',1)" onMouseOut="MM_swapImgRestore()"><img...
6
by: stickdoctorq | last post by:
This is driving me nuts....I can't find a solution that works for the following: --------------- var tbl = document.getElementById("question1b"); var choiceOne = ; var choiceTwo = ; var...
1
by: Frank | last post by:
Does anyone knows why this string is nog working ? name = "sub" a textfield in a form function item(name,total, price) { window.document.form.name"".value = total; } thank you !
1
by: LRW | last post by:
Below is some of the code I'm using. I have a PHP page generating a list of items. I've made it so that each one has a radiobutton with a unique value. You can click on the radiobutton and it will...
3
by: jason | last post by:
I have a function that <body onload=..> sets some form values. However when i execute that functionf from external js file, i get erorrs and it dont work. The function sets the fields via ...
2
by: Arif Bangash | last post by:
Hi All, I have a form like this <form id="frmworld" name ="frm" method=POST action "https://select.worldpay.com/wcc/purchase" > <input type="hidden" name="instId" value="135242"> ...
2
by: hemong | last post by:
Hi, wondering if anyone can help me I have created a form and user id, password that allows the user to submit and all this works fine however I want to create another button next to the ' > '...
11
by: dkate777 | last post by:
Hi, Is anybody know how to pass textbox input value to another page. I am using document.secondform.fieldname.value=document.firstformname.fieldname.value but it's not working Thanks
3
by: PrabodhanP | last post by:
I hv following javascript form validation code works in IE but not in Mozilla-Firefox ...please suggest <script type="text/javascript"> function IsNumeric(strString) // check for valid...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.