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

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>
dplinnaneAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GwynforWebCommented:
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
GwynforWebCommented:
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)
Michel PlungjanIT ExpertCommented:
Yes you can, Gwyn
document.forms[0].elements["function_id[1][2]"][0].checked

No dom needed

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

GwynforWebCommented:
Ah yes of course! Did not think of that.
NetGrooveCommented:
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

devicCommented:
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>
jaysolomonCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.