473,385 Members | 1,919 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,385 software developers and data experts.

Radio Button onClick Javascript should call only once

gskoli
23
Dear all,
Let me tell you the scenario , i have called javascript function on radio button selection , Ex.
Suppose There are 3 Radio Button .
Let us consider i have clicked on one radio button then
javascript is called on that and
it get 'checked' But again if if i clicked on that radio ,
Then again it will call the javascript .
So i dont want to let it happen , If radio button value got changed then only javascript should call

Please help.
Sep 1 '10 #1
7 3808
JKing
1,206 Expert 1GB
Try using the onchange event instead of the onclick event.
Sep 1 '10 #2
gskoli
23
Well i dint got expected result let me give you some snippet of the code.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <input type='radio' name='productradio' id='proname' value='prod_name' onClick='document.frm.submit();' />Product Name&nbsp;&nbsp; 
  3. <input type='radio' name='productradio' id='procode' value='prod_code' onClick='document.frm.submit();' />Product Code&nbsp;&nbsp; 
  4. <input type='radio' name='productradio' id='cat_name' value='cat_name' onClick='document.frm.submit();' />Category Name&nbsp;&nbsp; 
  5. <input type='radio' name='productradio' id='cat_code' value='cat_code' onClick='document.frm.submit();' />Category Code
  6.  
Now if i have selected Category Name and again i am selecting that
then form should not submit .
Sep 3 '10 #3
JKing
1,206 Expert 1GB
Did you try using the onchange event as I suggested?

Expand|Select|Wrap|Line Numbers
  1. <input type='radio' name='productradio' id='proname' value='prod_name' onChange='document.frm.submit();' />Product Name&nbsp;&nbsp; 
  2. <input type='radio' name='productradio' id='procode' value='prod_code' onChange='document.frm.submit();' />Product Code&nbsp;&nbsp; 
  3. <input type='radio' name='productradio' id='cat_name' value='cat_name' onChange='document.frm.submit();' />Category Name&nbsp;&nbsp; 
  4. <input type='radio' name='productradio' id='cat_code' value='cat_code' onChange='document.frm.submit();' />Category Code
  5.  
Sep 3 '10 #4
gskoli
23
Yes , but dint get result...
Sep 3 '10 #5
JKing
1,206 Expert 1GB
Are you using any serverside code?

After you submit the form it clears the controls. You would need to save the state of the controls for this to work properly.
Sep 3 '10 #6
gskoli
23
Ya i am using perl , I have solved that problem , But Is there will be pure javascript solution to that . I have saved its status in hidden variable and used that.
Thanks
Sep 4 '10 #7
kovik
1,044 Expert 1GB
You seem confused.

You want a pure JavaScript solution, yet you also want to submit your form. The only way to submit a form without leaving a page is through AJAX, but I have a feeling that this isn't what you are trying to do either.


Describe exactly what you are trying to do instead of just telling us that "it didn't work."
Sep 4 '10 #8

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

Similar topics

3
by: lee | last post by:
Hello I need some javascript code I've written to handle 2 values from an HTML form. I've been successful using the "label" attribute (I've simplied the example below): <input type="radio"...
1
by: Marcelo Oliveto | last post by:
Hi .... I have a radiobutton list and a label in a webform. <asp:radiobuttonlist id="one" runat="server" CssClass="text" AutoPostBack="False" RepeatDirection="Horizontal"> <asp:ListItem...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
2
by: xazos79 | last post by:
Hi All, I've come across the problem of not being able to re-enable a radio button with javascript if its initial state has been disabled in the Page_Load() method of the code behind. Might i...
9
by: IchBin | last post by:
I can not see what the problem is with this script. I am just trying to set a radio button by calling setCheckedValue('abbr_letter', 'V'). Sorry I am new to javascript. <html> <head> <script...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
5
by: swatidesai0407 | last post by:
hi im validating radio buttons i create dis radio button in php based on some how many records of my query. i wrote a javascript to validate this buttons. wat i do is dat wen no radio button...
1
by: Mufasa | last post by:
I have a couple of radio buttons that make various things appear/disappear on the screen through JavaScript. All works great. Problem is I'll click a radio button, something will appear, I reload...
2
vivekgs2007
by: vivekgs2007 | last post by:
Hi i am doing a application that add the rate of the staff evaluation please go through o=it and need help <?php include("../db.php"); session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.