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

No dom needed
0
 
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
0
 
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)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

0
 
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>
0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.