Solved

onclick link check a checkbox,onclick a radio button uncheck another radio button.

Posted on 2003-11-21
8
2,800 Views
Last Modified: 2008-03-06
When click the link I want the checkbox checked, how can I do this.
//////////////////////////////PART 1///////////////////////////////////////////////////////////
<body>
<p><input type="checkbox" value="9" name="clean_function_group_id[1][1]">
<a href='index_setting.php?search=search'>Search Replace<br>
//////////////////////////////PART 2///////////////////////////////////////////////////////////
IF Format Telephone is checked I need either of Format 1 or Farmat 2 checked.
If Custom Telephone is checked I need Format Telephone unchecked as well as either Format 1 or Format 2.
Thanks in advance.

<input type="radio" CHECKED value="3" name="function_group_id[1][2]">Format Telephone<br>
           <input class="t_50_15_black" type="radio" CHECKED value="9" name="function_id[1][2]">Format 1<br>
           <input class="t_50_15_black" type="radio" value="10" name="function_id[1][2]">Format 2</p>

<input type="radio" CHECKED value="44" name="form_wr_cff_clean_function_group_id[1][2]">
</body>
0
Comment
Question by:dplinnane
8 Comments
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 9801435
function_group_id[1][2] is an illegal identifier the options can only be accessed through the DOM arrys and we must see the form they are in top do this. Changing the name allows this though

<input type="checkbox" value="9" name="clean_function_group_id11">
<a href='#' onclick="clean_function_group_id11.NAME OFTHE FORM.checked=1; document.location='index_setting.php?search=search' ">Search Replace<br>

NAME OFTHE FORM is the name of the form the checkbox is in

I do not follow the 2nd part
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 9801450
does "IF Format Telephone is checked I need either of Format 1 or Farmat 2 checked."

mean Format Telephone can only be checked if Format 1 or Farmat 2 are checked

with the same logic for

"If Custom Telephone is checked I need Format Telephone unchecked as well as either Format 1 or Format 2."

ie I can only check Custom Telephoe if the conditions above are met, (i assume it is the last box)
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 168 total points
ID: 9801575
Yes you can, Gwyn
document.forms[0].elements["function_id[1][2]"][0].checked

No dom needed
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 31

Expert Comment

by:GwynforWeb
ID: 9801788
Ah yes of course! Did not think of that.
0
 
LVL 10

Assisted Solution

by:NetGroove
NetGroove earned 166 total points
ID: 9802150
is this what you asked for:


<head>
<script>
</script>
</head>
//////////////////////////////PART 1///////////////////////////////////////////////////////////
<body>
<form action="index_setting.php?search=search" name="form_wr_cff_clean">
<p><input type="checkbox" value="9" name="function_group_id[1][1]">
<b onClick="cb=document.form_wr_cff_clean['function_group_id[1][1]'];cb.checked=!cb.checked;">Search Replace</b><br>
//////////////////////////////PART 2///////////////////////////////////////////////////////////<br>
IF Format Telephone is checked I need either of Format 1 or Farmat 2 checked.<br>
If Custom Telephone is checked I need Format Telephone unchecked as well as either Format 1 or Format 2.<br>
Thanks in advance.<br>
<br>
<input type="radio" CHECKED value="3" name="function_group_id[1][2]"><b onClick="rb=document.form_wr_cff_clean['function_group_id[1][2]'][0];rb.checked=!rb.checked;db=document.form_wr_cff_clean['function_id[1][2]'];if(rb.checked==true)db[0].checked=true;else for(i=0;i<db.length;i++)db[i].checked=false;">Format Telephone</b><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class="t_50_15_black" type="radio" CHECKED value="9" name="function_id[1][2]">Format 1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class="t_50_15_black" type="radio" value="10" name="function_id[1][2]">Format 2</p>

<input type="radio" value="44" name="function_group_id[1][2]"><b onClick="rb=document.form_wr_cff_clean['function_group_id[1][2]'][1];rb.checked=!rb.checked;db=document.form_wr_cff_clean['function_id[1][2]'];if(rb.checked==false)db[0].checked=true;else for(i=0;i<db.length;i++)db[i].checked=false;">Custom Telephone</b><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="xyz">
</form>
</body>


And please note the empty <head> section.
There is normaly the place where such processing should be placed.

Tell me what you think.

Cheers,
NetGroove

0
 
LVL 25

Assisted Solution

by:devic
devic earned 166 total points
ID: 9802538
hi dplinnane,

here is my version ;)


=============================
<!--
When click the link I want the checkbox checked, how can I do this.
//////////////////////////////PART 1///////////////////////////////////////////////////////////
 -->
 <script>
function switchT(obj,m)
{
      var fg12=obj.elements["function_group_id[1][2]"];
      var f12=obj.elements["function_id[1][2]"];
      var fwccfg12=obj.elements["form_wr_cff_clean_function_group_id[1][2]"];
      if(m==2){fg12.checked=!fwccfg12.checked;}
      else{fwccfg12.checked=!fg12.checked;}
      f12[0].checked=fg12.checked;
      f12[1].checked=false;
      f12[0].disabled=fwccfg12.checked;
      f12[1].disabled=fwccfg12.checked;
}
</script>

<body>
<pre>
<form name=myform>
<input type="checkbox" value="9" id=clean_function_group_id_1_1 name="clean_function_group_id[1][1]"><label for=clean_function_group_id_1_1>Search Replace</label>
<!--
//////////////////////////////PART 2///////////////////////////////////////////////////////////
IF Format Telephone is checked I need either of Format 1 or Farmat 2 checked.
If Custom Telephone is checked I need Format Telephone unchecked as well as either Format 1 or Format 2.
Thanks in advance.
 -->
 
<input checked onclick="switchT(this.form,1)" type="radio" value="3" name="function_group_id[1][2]">Format Telephone<br>
      <input class="t_50_15_black" type="radio" value="9" name="function_id[1][2]">Format 1<br>
      <input class="t_50_15_black" type="radio" value="10" name="function_id[1][2]">Format 2
      
<input onclick="switchT(this.form,2)" type="radio" value="44" name="form_wr_cff_clean_function_group_id[1][2]">Custom Telephone
      <input type=text name=costum_tel>

</form>
</body>
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10383543
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: mplungjan {http:#9801575} & NetGroove {http:#9802150} & devic {http:#9802538}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now