/    Sign up×
Community /Pin to ProfileBookmark

resetting checkboxes and radios

Is it posiable to nove th value for the [COLOR=red]“item_name”[/COLOR] text box to the[COLOR=red]“result1”[/COLOR] text box and reseting the checkboxes and radio for the next set of information? I want to be able to do this for [COLOR=red]“result1″,”result2″,”result3”[/COLOR]
text boxes using the [COLOR=blue]“move total below”[/COLOR] button.

to post a comment
JavaScript

20 Comments(s)

Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [font=monospace]

document.forms["form_name"].name_of_element.value = document.forms["first_form_name"].name_of_first_form_element.value;

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@gogotinaauthorOct 22.2003 — sorry the code did not go.......

[upl-file uuid=c0e9271c-b67d-40b8-9f32-4063a312b859 size=7kB]help.txt[/upl-file]
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [font=monospace]

<input type="button" value="move total below" onclick="KeepCount(this.form)"><br>

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@gogotinaauthorOct 22.2003 — I still and not get the code to go..

lets tru this

<script language="javascript">

function KeepCount(form)

{

var checked = 0;


var maxnum = 5;

var i;

var Coma=',';

form.item_1.value = '';

form.item_2.value = '';

form.item_name.value = '';

for(i=0;i<form.length;i++)

{

if(form.elements[i].type == 'checkbox' && form.elements[i].checked)

{

if(checked < maxnum)

{

form.item_1.value += form.elements[i].value;

checked++;

}

else

{

alert('You are only allowed to pick ' + maxnum + ' items');

form.item_name.value += form.item_1.value ;

return false;

}

}

if(form.elements[i].type == 'radio' && form.elements[i].checked)

{

form.item_2.value += form.elements[i].value ;

}

}

form.item_name.value += form.item_1.value ;

form.item_name.value += Coma ;

form.item_name.value += form.item_2.value ;

return true;

}

</script>

<form name="item1"><input type="text" name="item_1" value="checkboxes"><input type="text" name="item_2" value="radios"><input type="text" name="item_name" value="total"><small><br>

<input type="checkbox" value="01" onclick="return KeepCount(this.form)"></small><small> 1&nbsp;</small><small><input type="checkbox" value="02" onclick="return KeepCount(this.form)"></small><small>

2&nbsp; </small><small><input type="checkbox" value="03" onclick="return KeepCount(this.form)"></small><small>

3&nbsp;</small><small><input type="checkbox" value="04" onclick="return KeepCount(this.form)"></small><small>

4&nbsp; </small><small><input type="checkbox" value="05" onclick="return KeepCount(this.form)"></small><small>

5&nbsp;</small><small><input type="checkbox" value="06" onclick="return KeepCount(this.form)"></small><small>

6&nbsp; </small><small><input type="checkbox" value="07" onclick="return KeepCount(this.form)"></small><small>

7&nbsp;</small><small><input type="checkbox" value="08" onclick="return KeepCount(this.form)"></small><small>

8&nbsp; </small><small><input type="checkbox" value="09" onclick="return KeepCount(this.form)"></small><small>

9&nbsp;</small><small><input type="checkbox" value="10" onclick="return KeepCount(this.form)"></small><small>

10&nbsp; </small><small><input type="checkbox" value="11" onclick="return KeepCount(this.form)"></small><small>

11&nbsp;</small><small><input type="checkbox" value="12" onclick="return KeepCount(this.form)"></small><small>

12&nbsp; </small><small><input type="checkbox" value="13" onclick="return KeepCount(this.form)"></small><small>

13&nbsp;</small><small><input type="checkbox" value="14" onclick="return KeepCount(this.form)"></small><small>

14&nbsp; </small><small><input type="checkbox" value="15" onclick="return KeepCount(this.form)"></small><small>

15&nbsp;</small><small><input type="checkbox" value="16" onclick="return KeepCount(this.form)"></small><small>

16&nbsp; </small><small><input type="checkbox" value="17" onclick="return KeepCount(this.form)"></small><small>

17&nbsp;</small><small><input type="checkbox" value="18" onclick="return KeepCount(this.form)"></small><small>

18&nbsp; </small><small><input type="checkbox" value="19" onclick="return KeepCount(this.form)"></small><small>

19&nbsp;</small><small><input type="checkbox" value="20" onclick="return KeepCount(this.form)"></small>

20&nbsp; <small><br>

</small><br>

<small><input type="radio" name="item2" value="1" onclick="return KeepCount(this.form)"></small><small>

1&nbsp;</small><small><input type="radio" name="item2" value="2" onclick="return KeepCount(this.form)"></small><small>

2&nbsp; </small><small><input type="radio" name="item2" value="3" onclick="return KeepCount(this.form)"></small><small>

3&nbsp;</small><small><input type="radio" name="item2" value="4" onclick="return KeepCount(this.form)"></small><small>

4&nbsp; </small><small><input type="radio" name="item2" value="5" onclick="return KeepCount(this.form)"></small><small>

5&nbsp;</small><small><input type="radio" name="item2" value="6" onclick="return KeepCount(this.form)"></small><small>

6&nbsp; </small><small><input type="radio" name="item2" value="7" onclick="return KeepCount(this.form)"></small><small>

7&nbsp;</small><small><input type="radio" name="item2" value="8" onclick="return KeepCount(this.form)"></small><small>

8&nbsp; </small><small><input type="radio" name="item2" value="9" onclick="return KeepCount(this.form)"></small><small>

9&nbsp;</small><small><input type="radio" name="item2" value="10" onclick="return KeepCount(this.form)"></small><small>

10 </small><br>

<input type="button" value="move total below"><br>

<input type="text" name="result1" value="result1"><input type="text" name="result2" value="result2"><input type="text" name="result3" value="result3"></form>



</body>

</html>
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [font=arial][color=maroon]Is this what you want?[/color][/font]

[font=monospace]

<script language="javascript">

function keepCount(f) {

var checked = 0, maxnum = 5, i, Coma=',';

f.item_1.value = '';

f.item_2.value = '';

f.item_name.value = '';

for(i=0;i<f.elements.length;i++){

if(f.elements[i].type == 'checkbox' && f.elements[i].checked){

if(checked < maxnum){

f.item_1.value += f.elements[i].value;

checked++;

}

else{

alert('You are only allowed to pick ' + maxnum + ' items');

f.item_name.value += f.item_1.value;

return false;

}

}

if(f.elements[i].type == 'radio' && f.elements[i].checked){

f.item_2.value += f.elements[i].value;

}

}



if(f.item_name.value != ""){

f.item_name.value += ","+f.item_1.value;

} else {

f.item_name.value += f.item_1.value;

}

f.item_name.value += f.item_2.value;

return true;

}

function moveData(f){

f.result1.value = f.item_1.value;

f.result2.value = f.item_2.value;

f.result3.value = f.item_name.value;

}

</script>

<form name="item1"><input type="text" name="item_1" value="checkboxes"><input type="text" name="item_2" value="radios"><input type="text" name="item_name" value="total"><small><br>

<input type="checkbox" value="01" onclick="return keepCount(this.form)"></small><small>

1&nbsp;</small><small><input type="checkbox" value="02" onclick="return keepCount(this.form)"></small><small>

2&nbsp; </small><small><input type="checkbox" value="03" onclick="return keepCount(this.form)"></small><small>

3&nbsp;</small><small><input type="checkbox" value="04" onclick="return keepCount(this.form)"></small><small>

4&nbsp; </small><small><input type="checkbox" value="05" onclick="return keepCount(this.form)"></small><small>

5&nbsp;</small><small><input type="checkbox" value="06" onclick="return keepCount(this.form)"></small><small>

6&nbsp; </small><small><input type="checkbox" value="07" onclick="return keepCount(this.form)"></small><small>

7&nbsp;</small><small><input type="checkbox" value="08" onclick="return keepCount(this.form)"></small><small>

8&nbsp; </small><small><input type="checkbox" value="09" onclick="return keepCount(this.form)"></small><small>

9&nbsp;</small><small><input type="checkbox" value="10" onclick="return keepCount(this.form)"></small><small>

10&nbsp; </small><small><input type="checkbox" value="11" onclick="return keepCount(this.form)"></small><small>

11&nbsp;</small><small><input type="checkbox" value="12" onclick="return keepCount(this.form)"></small><small>

12&nbsp; </small><small><input type="checkbox" value="13" onclick="return keepCount(this.form)"></small><small>

13&nbsp;</small><small><input type="checkbox" value="14" onclick="return keepCount(this.form)"></small><small>

14&nbsp; </small><small><input type="checkbox" value="15" onclick="return keepCount(this.form)"></small><small>

15&nbsp;</small><small><input type="checkbox" value="16" onclick="return keepCount(this.form)"></small><small>

16&nbsp; </small><small><input type="checkbox" value="17" onclick="return keepCount(this.form)"></small><small>

17&nbsp;</small><small><input type="checkbox" value="18" onclick="return keepCount(this.form)"></small><small>

18&nbsp; </small><small><input type="checkbox" value="19" onclick="return keepCount(this.form)"></small><small>

19&nbsp;</small><small><input type="checkbox" value="20" onclick="return keepCount(this.form)"></small>

20&nbsp; <small><br>

</small><br>

<small><input type="radio" name="item2" value="1" onclick="return keepCount(this.form)"></small><small>

1&nbsp;</small><small><input type="radio" name="item2" value="2" onclick="return keepCount(this.form)"></small><small>

2&nbsp; </small><small><input type="radio" name="item2" value="3" onclick="return keepCount(this.form)"></small><small>

3&nbsp;</small><small><input type="radio" name="item2" value="4" onclick="return keepCount(this.form)"></small><small>

4&nbsp; </small><small><input type="radio" name="item2" value="5" onclick="return keepCount(this.form)"></small><small>

5&nbsp;</small><small><input type="radio" name="item2" value="6" onclick="return keepCount(this.form)"></small><small>

6&nbsp; </small><small><input type="radio" name="item2" value="7" onclick="return keepCount(this.form)"></small><small>

7&nbsp;</small><small><input type="radio" name="item2" value="8" onclick="return keepCount(this.form)"></small><small>

8&nbsp; </small><small><input type="radio" name="item2" value="9" onclick="return keepCount(this.form)"></small><small>

9&nbsp;</small><small><input type="radio" name="item2" value="10" onclick="return keepCount(this.form)"></small><small>

10 </small><br>

<input type="button" value="move total below" onclick="moveData(this.form)"><br>

<input type="text" name="result1" value="result1"><input type="text" name="result2" value="result2"><input type="text" name="result3" value="result3"></form>



</body>

</html>

[/font]



[b][J]ona[/b]
Copy linkTweet thisAlerts:
@gogotinaauthorOct 22.2003 — not quite. I would like the [COLOR=red]move total below[/COLOR] button to move the value of[COLOR=red]"item_name"[/COLOR] to [COLOR=red]"result1"[/COLOR] then clear/rest the values for [COLOR=red]item_1, item_2, item_name[/COLOR] so it can be done again for [COLOR=red]"result2"[/COLOR]. I guess that I am trying to loop through the checkboxes and radios 3 times and displaying the information collected in [COLOR=red]"result1", "result2","result3"[/COLOR]
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [font=arial][color=maroon]Replace the above moveData() function with this one:[/color][/font]

[font=monospace]

function moveData(f){

if(f.result1.value=="result1")

{f.result1.value = f.item_name.value;}

if(f.result2.value=="result2" && f.result1.value != "result1")

{f.result2.value = f.item_name.value;}

if(f.result3.value=="result3" && f.result2.value != "result2")

{f.result3.value = f.item_name.value;}

}

[/font]

[i]Edited the code.[/i]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [font=arial][color=maroon]Okay, scratch again... Try this...[/color][/font]

[font=monospace]

function moveData(f){

if(f.result3.value=="result3" && f.result2.value != "result2")

{f.result3.value = f.item_name.value;}

if(f.result2.value=="result2" && f.result1.value != "result1")

{f.result2.value = f.item_name.value;}

if(f.result1.value=="result1")

{f.result1.value = f.item_name.value;}

}

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@gogotinaauthorOct 22.2003 — well... the [COLOR=red]"move total below"[/COLOR] button moves the info into all tree [COLOR=red]"result"[/COLOR] text boxes and it dose not reset the checkboxes and radios to [COLOR=blue]unchecked[/COLOR] status. ???
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [font=monospace]

function moveData(f){

if(f.item_name.value != "total"){

if(f.result3.value=="result3" && f.result2.value != "result2")

{f.result3.value = f.item_name.value;}

if(f.result2.value=="result2" && f.result1.value != "result1")

{f.result2.value = f.item_name.value;}

if(f.result1.value=="result1")

{f.result1.value = f.item_name.value;}

} }

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@gogotinaauthorOct 22.2003 — close.. it still dose not clear the checkboxes or radios.
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [i]Originally posted by gogotina [/i]

[B]close.. it still dose not clear the checkboxes or radios. [/B][/QUOTE]


[font=arial][color=maroon]Didn't remember that part...[/color][/font]

[font=monospace]

function moveData(f){

if(f.item_name.value != "total"){

if(f.result3.value=="result3" && f.result2.value != "result2")

{f.result3.value = f.item_name.value;}

if(f.result2.value=="result2" && f.result1.value != "result1")

{f.result2.value = f.item_name.value;}

if(f.result1.value=="result1")

{f.result1.value = f.item_name.value;}

}

for(m=0; m<f.elements.length; m++){

if(f.elements[m].type == "checkbox" || f.elements[m].type == "radio" && f.elements[m].checked){

f.elements[m].checked=false;

} }

}

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@gogotinaauthorOct 22.2003 — GREAT... but it dose not reset the checkboxes and radios until one of them is clicked and we losted the camas between the checkbox totals and the radio.
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [i]Originally posted by gogotina [/i]

[B]GREAT... but it dose not reset the checkboxes and radios until one of them is clicked and we losted the camas between the checkbox totals and the radio. [/B][/QUOTE]


[font=monospace]

function keepCount(f) {

var checked = 0, maxnum = 5, i, Coma=',';

f.item_1.value = '';

f.item_2.value = '';

f.item_name.value = '';

for(i=0;i<f.elements.length;i++){

if(f.elements[i].type == 'checkbox' && f.elements[i].checked){

if(checked < maxnum){

f.item_1.value += f.elements[i].value;

checked++;

}

else{

alert('You are only allowed to pick ' + maxnum + ' items');

f.item_name.value += f.item_1.value;

return false;

}

}

if(f.elements[i].type == 'radio' && f.elements[i].checked){

f.item_2.value += f.elements[i].value;

}

}



f.item_name.value += f.item_1.value+",";



f.item_name.value += f.item_2.value;

return true;

}

[/font]



[b][J]ona[/b]
Copy linkTweet thisAlerts:
@gogotinaauthorOct 22.2003 — still dose not reset the checkboxes and radio until one of the are clicked. Can they be reset with the [COLOR=red]"onclick"[/COLOR] of the[COLOR=red]"move total below"[/COLOR] button?
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [i]Originally posted by gogotina [/i]

[B]still dose not reset the checkboxes and radio until one of the are clicked. Can they be reset with the [COLOR=red]"onclick"[/COLOR] of the[COLOR=red]"move total below"[/COLOR] button? [/B][/QUOTE]


[font=arial][color=maroon]I do not understand that... [/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@gogotinaauthorOct 22.2003 — I'm sorry. The checkboxes and radios are being reset. The values for [COLOR=red]f.item_1, f.item_2, and item_name[/COLOR] are what I was looking at. Can we reset them too?
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [font=monospace]

function moveData(f){

if(f.item_name.value != "total"){

if(f.result3.value=="result3" && f.result2.value != "result2")

{f.result3.value = f.item_name.value;}

if(f.result2.value=="result2" && f.result1.value != "result1")

{f.result2.value = f.item_name.value;}

if(f.result1.value=="result1")

{f.result1.value = f.item_name.value;}

}

for(m=0; m<f.elements.length; m++){

if(f.elements[m].type == "checkbox" || f.elements[m].type == "radio" && f.elements[m].checked){

f.elements[m].checked=false;

} }

f.item_1.value="";

f.item_2.value="";

f.item_name.value="";

}

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@gogotinaauthorOct 22.2003 — ? ? ? THNXXXX ? ? ?
Copy linkTweet thisAlerts:
@JonaOct 22.2003 — [font=arial][color=green]You're welcome.[/color][/font]

[b][J]ona[/b]
×

Success!

Help @gogotina 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.18,
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,
)...