Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-11-21
8
Medium Priority
?
2,845 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

661 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