Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2003-11-21
8
Medium Priority
?
2,858 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 672 total points
ID: 9801575
Yes you can, Gwyn
document.forms[0].elements["function_id[1][2]"][0].checked

No dom needed
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 664 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 664 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

885 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