how can i send two parameters in a script?

fedkris
fedkris used Ask the Experts™
on
we have a form, (see file attached), when i select a box, the radio button "yes" should be selected by script

<SCRIPT>
function GETONcheck(i)
{
document.getElementById(i).checked = true;

}
</SCRIPT>

Open in new window



 	<INPUT id=radio8 type=radio name=q17 value="1" <% if fq17 = "1" then response.write "checked" end if  %> >
  				<%=q20%>&nbsp;</td>
			   	<td>
				</td>
		   	</tr>
			 <tr>
			   	<td style="height: 21px">
			   	<INPUT id=radio9 type=radio name=q17 value="2" <% if fq17 = "2" then response.write "checked" end if  %>>
			   	<%=q21 %>&nbsp;</td>
			   	<td style="height: 21px"></td>
	   		 </tr>

	   		 
	   		 
		   	
			   		 
			   		 
			   		 
					 <tr>
					
			   	<td>
			   	<table cellpadding="0" cellspacing="0" style="width: 100%">
					<tr>
						<td width="25px">&nbsp;</td>
						<td><INPUT id=q18 type=checkbox name=q18 onchange="GETONcheck('q17')"  <%if request.querystring("fq18") = "on" then response.write "checked" end if  %>>&nbsp;<%=q30 %></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td><INPUT id=q19 type=checkbox name=q19 onchange="GETONcheck('q17')" <%if request.querystring("fq19") = "on" then response.write "checked" end if  %>>&nbsp;<%=q31 %></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td><INPUT id=q20 type=checkbox name=q20 onchange="GETONcheck('q17')" <%if request.querystring("fq20") = "on" then response.write "checked" end if  %>>&nbsp;<%=q32 %></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
				</table>

Open in new window




so, if i check box 18, 19 or 20, radiobutton 17 has to be checked, with value 2 (in this case, true).

you know how to do that?
B--script.png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Luis PérezSoftware Architect in .Net

Commented:
Replace your
onchange="GETONcheck('q17')"
with
onchange="GETONcheck('radio9')"

Because inside GETONcheck you use GetElementById, the Id of the radiobutton is "radio9", not "q17".

Hope that helps.

Author

Commented:
hi, thx for answer, when i change that, he doesn't check the checkbox (yes)...
Luis PérezSoftware Architect in .Net

Commented:
Have you changed it in all your checkboxes (three of them)?
Should you be charging more for 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 using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
yes, but it doesn"t work
Luis PérezSoftware Architect in .Net

Commented:
Can you post your actual code (with changes inserted)?
Owner (Aidellio)
Most Valuable Expert 2015
Commented:
I think  you need a structure to control your logic such as knockoutjs & jquery

Here is a demo of what you want utilising knockout: http://jsbin.com/necij/1/edit?html,js,output

<!DOCTYPE html>
<html>
	<head>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/knockout/3.0.0/knockout-min.js"></script>
		<meta charset="utf-8">
		<title>JS Bin</title>
	</head>
	<body>
		<table>
			<tr><td>
		<input id='radio8' type='radio' name='q17' value="1" data-bind="enable: mytest()==1,checked: mytest"/>q17-1
		&nbsp;</td>
		<td>
		</td>
		</tr>
	<tr>
		<td style="height: 21px">
			<input id='radio9' type='radio' name='q17' value="2" data-bind="checked: mytest"/>q17-2
			&nbsp;</td>
		<td style="height: 21px"></td>
	</tr>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" style="width: 100%">
				<tr>
					<td width="25px">&nbsp;</td>
					<td><input id='q18' type='checkbox' name='q18' data-bind="checked: q18" />q18</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input id='q19' type="checkbox" name='q19' data-bind="checked: q19" />q19</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input id='q20' type='checkbox' name='q20' data-bind="checked: q20" />q20</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>
			</table>
	</body>
</html>

Open in new window


$(function() {
	viewmodel = {
		q18: ko.observable(false),
		q19: ko.observable(false),
		q20: ko.observable(false),
		myradio: ko.observable()
	};
	viewmodel.mytest = ko.computed({
		read: 
		function(){
			if (viewmodel.q18() || viewmodel.q19() || viewmodel.q20())
				return "2";

			return "1";
		},
		write: function(val) {
			viewmodel.myradio(val);
		}
	});

	ko.applyBindings(viewmodel);
});

Open in new window

Expert of the Year 2014
Top Expert 2014

Commented:
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
RobOwner (Aidellio)
Most Valuable Expert 2015

Commented:
Fully working demo in my comment

http:#a40243127

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial