/    Sign up×
Community /Pin to ProfileBookmark

checkbox javascript help needed

I need a system in JavaScript where if you choose any 2 starred items from the list, the price for the printer reduces to £54.99. Also, if someone chooses the Upgraded CPU option, they are allowed to upgrade to Win XP 64 Bit Edition. Please help! Thanks in advance!

[code=html]<table border=”0″>
<tr>
<td>CPU to Dual 64-bit 2.66GHz</td>
<td><input type=”checkbox” value=”yes” name=”cpudual”></td>
</tr>
<tr>
<td>RAM to 2GB*</td>
<td><input type=”checkbox” value=”yes” name=”ram2gb”></td>
</tr>
<tr>
<td>RAM to 1.5GB*</td>
<td><input type=”checkbox” value=”yes” name=”ram1gb”></td>
</tr>
<tr>
<td>HDD to 250GB*</td>
<td><input type=”checkbox” value=”yes” name=”hdd250gb”></td>
</tr>
<tr>
<td>256MB Graphics Card*</td>
<td><input type=”checkbox” value=”yes” name=”graphics”></td>
</tr>
<tr>
<td>Monitor to 20&quot; <small>(graphics card required)*</small></td>
<td><input type=”checkbox” value=”yes” name=”20monitor”></td>
</tr>
<tr>
<td>Micro ATX case (silver cube)*</td>
<td><input type=”checkbox” value=”yes” name=”microatx”>

<tr>
<td>Win XP 64-bit (only with extended processor) </td>
<td><input name=”winxp64″ type=”checkbox” id=”winxp64″ disabled=”disabled” value=”yes”>
<tr>
<td>Printer</td>
<td>&pound;64.99
</table>
<p>
<input type=”submit”>
</p>[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@JUDOct 01.2006 — [code=html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
// <![CDATA[
var starredOptions = 0;

function checkedOptions(elem){
var nme = elem.name;

switch(nme){
case "cpudual":
elem.form["winxp64"].disabled = (elem.checked) ? false : true;
break;
case "ram2gb":
starredOptions = (elem.checked) ? starredOptions + 1 : starredOptions - 1;
break;
case "ram1gb":
starredOptions = (elem.checked) ? starredOptions + 1 : starredOptions - 1;
break;
case "hdd250gb":
starredOptions = (elem.checked) ? starredOptions + 1 : starredOptions - 1;
break;
case "graphics":
starredOptions = (elem.checked) ? starredOptions + 1 : starredOptions - 1;
break;
case "microatx":
starredOptions = (elem.checked) ? starredOptions + 1 : starredOptions - 1;
break;
case "20monitor":
starredOptions = (elem.checked) ? starredOptions + 1 : starredOptions - 1;
break;
}

document.getElementById("printer_price").firstChild.data = (starredOptions >= 2) ? "£54.99" : "£64.99";
}
// ]]>
</script>
</head>

<body>
<form>
<table border="0">
<tr>
<td>CPU to Dual 64-bit 2.66GHz</td>

<td><input type="checkbox" value="yes" name="cpudual" onclick="checkedOptions(this)" /></td>

</tr>

<tr>

<td>RAM to 2GB*</td>

<td><input type="checkbox" value="yes" name="ram2gb" onclick="checkedOptions(this)" /></td>
</tr>
<tr>
<td>RAM to 1.5GB*</td>
<td><input type="checkbox" value="yes" name="ram1gb" onclick="checkedOptions(this)" /></td>
</tr>
<tr>
<td>HDD to 250GB*</td>
<td><input type="checkbox" value="yes" name="hdd250gb" onclick="checkedOptions(this)" /></td>
</tr>

<tr>
<td>256MB Graphics Card*</td>

<td><input type="checkbox" value="yes" name="graphics" onclick="checkedOptions(this)" /></td>

</tr>

<tr>
<td>Monitor to 20&quot; <small>(graphics card required)*</small></td>

<td><input type="checkbox" value="yes" name="20monitor" onclick="checkedOptions(this)" /></td>

</tr>

<tr>

<td>Micro ATX case (silver cube)*</td>

<td><input type="checkbox" value="yes" name="microatx" onclick="checkedOptions(this)" /></td>
</tr>

<tr>

<td>Win XP 64-bit (only with extended processor) </td>

<td><input name="winxp64" type="checkbox" id="winxp64" disabled="disabled" value="yes" /></td>
</tr>
<tr>

<td>Printer</td>

<td id="printer_price">&pound;64.99</td>
</tr>
</table>
<p><input type="submit" /></p>
</form>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@quirkeyauthorOct 02.2006 — Thank you [B]so[/B] much! It's brilliant!
×

Success!

Help @quirkey spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...