The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Help with Check box and values
cosmoslyn
post Mar 14 2012, 08:27 PM
Post #1





Group: Members
Posts: 4
Joined: 14-March 12
Member No.: 16,706



Hi,

I am doing a special table for my boss, and I seem to be unable to get the table to work,

Basically:
Question: Are you free?
Check box at the second column
on the 3rd column I would like to do : if checked, score 1 (1 point) if unchecked score zero... or nothing

would show hidden be good? But I would like to add a sum of all the points later too. blink.gif

Thank someone help me thanks?
I know it sounds easy, but I haven't been getting it to work.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 15 2012, 06:50 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,660
Joined: 10-August 06
Member No.: 7



This can't be done with HTML alone, you need some kind of script --javascript if the page must not be reloaded between checkbox checks, otherwise a serverside (e.g. PHP or ASP).

What is the purpose of the points --are they just for the user's information, or are they stored somewhere?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
cosmoslyn
post Mar 15 2012, 05:37 PM
Post #3





Group: Members
Posts: 4
Joined: 14-March 12
Member No.: 16,706



I am doing a table for a project, it's called a depression scale,
it is a yes/ no answer to a few statements and at the end you get a score.
So the scores are for user information only

I have been trying to use java script, the box ticks but I can't seem to get the score to show .
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 15 2012, 05:47 PM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,732
Joined: 9-August 06
Member No.: 6



It helps if you show what you've got so far. Otherwise we can't know what's wrong.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
cosmoslyn
post Mar 18 2012, 11:21 PM
Post #5





Group: Members
Posts: 4
Joined: 14-March 12
Member No.: 16,706



QUOTE(pandy @ Mar 15 2012, 05:47 PM) *

It helps if you show what you've got so far. Otherwise we can't know what's wrong.

CODE

<td class='ee112' sheetid="2" rowid="3" colid="1">
Questions


</td>
<td class='ee112' sheetid="2" rowid="3" colid="2">
Tick if Yes


</td>
<td class='ee106' sheetid="2" rowid="3" colid="3">
Score


</td>
</tr>
<tr style='height:15pt'>
<td class='ee103' sheetid="2" rowid="4" colid="1">
Are you basically satisfied with your
  life?


</td>
<td class='ee115' sheetid="2" rowid="4" colid="2">
<input onClick="recalc_onclick('XLEW_2_4_2')" type='checkbox' tabindex='1' style='padding-right:1px;' name='XLEW_2_4_2' id='XLEW_2_4_2' class='ee105' downkey='XLEW_2_5_2' onKeyDown="onEnterPress('XLEW_2_4_2');" />


</td>
<td class='ee116' sheetid="2" rowid="4" colid="3">
<input readonly='readonly' value='0' type='text' tabindex='-1' style='overflow:hidden; border:0px solid #000000; width:100%;padding-right:1px;' name='XLEW_2_4_3' id='XLEW_2_4_3' class='ee108' />


</td>
</tr>
<tr style='height:15pt'>
<td class='ee103' sheetid="2" rowid="5" colid="1">
Have you dropped many of your activities
  and interests?


</td>
<td class='ee115' sheetid="2" rowid="5" colid="2">
<input onClick="recalc_onclick('XLEW_2_5_2')" type='checkbox' tabindex='2' style='padding-right:1px;' name='XLEW_2_5_2' id='XLEW_2_5_2' class='ee105' downkey='XLEW_2_6_2' upkey='XLEW_2_4_2' onKeyDown="onEnterPress('XLEW_2_5_2');" />


</td>
<td class='ee116' sheetid="2" rowid="5" colid="3">
<input readonly='readonly' value='0' type='text' tabindex='-1' style='overflow:hidden; border:0px solid #000000; width:100%;padding-right:1px;' name='XLEW_2_5_3' id='XLEW_2_5_3' class='ee108' />


</td>
</tr>
<tr style='height:15pt'>
<td class='ee103' sheetid="2" rowid="6" colid="1">
Do you feel that your life is empty?


</td>
<td class='ee115' sheetid="2" rowid="6" colid="2">
<input onClick="recalc_onclick('XLEW_2_6_2')" type='checkbox' tabindex='3' style='padding-right:1px;' name='XLEW_2_6_2' id='XLEW_2_6_2' class='ee105' upkey='XLEW_2_5_2' onKeyDown="onEnterPress('XLEW_2_6_2');" />


</td>
<td class='ee116' sheetid="2" rowid="6" colid="3">
<input readonly='readonly' value='0' type='text' tabindex='-1' style='overflow:hidden; border:0px solid #000000; width:100%;padding-right:1px;' name='XLEW_2_6_3' id='XLEW_2_6_3' class='ee108' />


</td>
</tr>
<tr style='height:15pt'>
<td class='ee103' sheetid="2" rowid="7" colid="1">
Do you often get bored?


</td>
<td class='ee103' sheetid="2" rowid="7" colid="2"><span class="ee115">
<input onClick="recalc_onclick('XLEW_2_7_2')" type='checkbox' tabindex='3' style='padding-right:1px;' name='XLEW_2_7_' id='XLEW_2_7_' class='ee105' upkey='XLEW_2_6_2' onKeyDown="onEnterPress('XLEW_2_8_2');" />
</span></td>
<td class='ee106' sheetid="2" rowid="7" colid="3"><input readonly='readonly' value='0' type='text' tabindex='-1' style='overflow:hidden; border:0px solid #000000; width:100%;padding-right:1px;' name='XLEW_2_6_3' id='XLEW_2_7_3' class='ee108' /></td>
</tr>
<tr style='height:15pt'>
<td class='ee103' sheetid="2" rowid="8" colid="1">
Are you in good spirits most of the time?


</td>
<td class='ee103' sheetid="2" rowid="8" colid="2"><input onClick="recalc_onclick('XLEW_2_8_2')" type='checkbox' tabindex='3' style='padding-right:1px;' name='XLEW_2_8_' id='XLEW_2_8_' class='ee105' upkey='XLEW_2_7_2' onKeyDown="onEnterPress('XLEW_2_9_2');" /></td>
<td class='ee106' sheetid="2" rowid="8" colid="3">&nbsp;</td>
</tr>
<tr style='height:15pt'>
<td class='ee103' sheetid="2" rowid="9" colid="1">
Are you afraid that something bad is
  going to happen to you?


</td>
<td class='ee103' sheetid="2" rowid="9" colid="2">
<input onClick="recalc_onclick('XLEW_2_9_2')" type='checkbox' tabindex='3' style='padding-right:1px;' name='XLEW_2_9_' id='XLEW_2_9_' class='ee105' upkey='XLEW_2_8_2' onKeyDown="onEnterPress('XLEW_2_10_2');" />
</td>
<td class='ee106' sheetid="2" rowid="9" colid="3">&nbsp;</td>
</tr>
<tr style='height:15pt'>
<td class='ee103' sheetid="2" rowid="10" colid="1">
Do you feel happy most of the time?


</td>
<td class='ee103' sheetid="2" rowid="10" colid="2"><input onClick="recalc_onclick('XLEW_2_10_2')" type='checkbox' tabindex='3' style='padding-right:1px;' name='XLEW_2_10_' id='XLEW_2_10_' class='ee105' upkey='XLEW_2_9_2' onKeyDown="onEnterPress('XLEW_2_11_2');" />
</td>
<td class='ee106' sheetid="2" rowid="10" colid="3">&nbsp;</td>


would that help?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 19 2012, 12:29 AM
Post #6


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,732
Joined: 9-August 06
Member No.: 6



And the script?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 19 2012, 01:15 AM
Post #7


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,732
Joined: 9-August 06
Member No.: 6



Maybe I misunderstand. Do you think that this will do something on its own?
CODE
onClick="recalc_onclick('XLEW_2_4_2')"


It won't. It's a call to a function called recalc_onlick() and it passes the parameter 'XLEW_2_4_2' to it. Since there is no function, all you get is a JavaScript error.

You need to to something along these lines.

HTML
<input type='checkbox' onclick="document.getElementById('foo').value='1'">

<input value='0' type='text' id='foo'>


Sorry if I misunderstood THIS time and you just left out the script. wink.gif

BTW you can't invent your own attributes like sheetid and rowid.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
cosmoslyn
post Mar 19 2012, 06:40 PM
Post #8





Group: Members
Posts: 4
Joined: 14-March 12
Member No.: 16,706



Not sure Pandy, I am grateful for your help, someone help me with that one so probably that is why I found it a bit confusing, no wonder it didn't work.

If I could just make it as a simple function would be great... would

HTML
<input type='checkbox' onclick="document.getElementById('foo').value='1'">

<input value='0' type='text' id='foo'>


be alright then?

QUOTE(pandy @ Mar 19 2012, 01:15 AM) *

Maybe I misunderstand. Do you think that this will do something on its own?
CODE
onClick="recalc_onclick('XLEW_2_4_2')"


It won't. It's a call to a function called recalc_onlick() and it passes the parameter 'XLEW_2_4_2' to it. Since there is no function, all you get is a JavaScript error.

You need to to something along these lines.

HTML
<input type='checkbox' onclick="document.getElementById('foo').value='1'">

<input value='0' type='text' id='foo'>


Sorry if I misunderstood THIS time and you just left out the script. wink.gif

BTW you can't invent your own attributes like sheetid and rowid.


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 19 2012, 07:32 PM
Post #9


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,732
Joined: 9-August 06
Member No.: 6



Yes. Just give each text input their own id and then use that id as in my example.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 07:29 PM