Go Back   HTMLCenter Web Development Forums > Web Design and Development > Programming and Scripting

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 06-06-2007, 09:03 AM
Registered User
 
Join Date: Jul 2004
Posts: 221
How to store checkbox values in hidden fields

How do you store the checkbox alues in a hidden field?
Code:
  <div id="divform" style="position:absolute;z-index:2; ">
<form name="frm" id="frm" action="../wait.html" method="post" >
<div id="set1" style="position:absolute; left:65px;top:146px;">

<span style="position:absolute; top: 170px; left: 180px;width:104px;">
<input name="check" id="check"  type="checkbox" onClick="photos_bought(this.value);" value="Ireland: picture 10 300dpi" />300dpi $100<br />
<input name="check" id="check"  type="checkbox" onClick="photos_bought(this.value);" value="Ireland: picture 10 600dpi" />600dpi $175</span>

<span style="position:absolute; left: 60px;  top:270px;width:104px;">
<input name="check" id="check"  type="checkbox" onClick="photos_bought(this.value);" value="Ireland: picture 1 300dpi" />300dpi $100<br />
<input name="check" id="check"  type="checkbox" onClick="photos_bought(this.value);" value="Ireland: picture 1 600dpi" />600dpi $175</span>

<span style="position:absolute; left: 307px; top:150px;width:71px;">
<textarea name="order" id="order" cols="50" rows="5"></textarea><br />
<input type="button" onClick="createOrder();openpopup();" value="Send order" /><input type="reset" value="Reset" /> 
</span>
</div>

</form>
Reply With Quote

  #2 (permalink)  
Old 06-06-2007, 07:58 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,396
gil - I think you need to start being a little more specific with your questions. With this question and your previous one, I am having a little trouble figuring out where you're having trouble, what you've tried, etc.

Regardless, I believe the answer to your question lies in Javascript. Your Javascript function should look something like:
Code:
function storeValue(what) {
if(what.checked = true) {
document.getElmentById('myHiddenField').value = what.value;
}
Your checkboxes should look something like:
Code:
<input type='checkbox' value='myValue' onchange='storeValue(this)' />
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
  #3 (permalink)  
Old 06-07-2007, 02:54 PM
Registered User
 
Join Date: Jul 2004
Posts: 221
Ok I think it worked the reason I want to store in the index from the iframe's iframe is to retrieve it in a popup window.
So here's what I have so far:
Code:
function createOrder(){
	clickable=document.forms[0].check
	txt=""
for (i=0;i<clickable.length;++ i){
	if (clickable[i].checked){
		txt=txt + clickable[i].value + " "
		}
	}
document.getElementById("order").value="You ordered: " + txt
}	

function storeValue(what) {
	var oreilly = new Array(); //to hold the answer from the user	
	
	oreilly[0] = parent.parent.document.getElementById("gal1").value;/*parent.parent.document.getElementById("gal1").value;*/ //copies the user buyer to index.html hidden field  
	oreilly[1] = parent.parent.document.getElementById("gal2").value; //copies the user buyer to index.html hidden field  
	oreilly[2] = parent.parent.document.getElementById("gal3").value; //copies the user buyer to index.html hidden field  
	oreilly[3] = parent.parent.document.getElementById("gal4").value; //copies the user buyer to index.html hidden field  		
	oreilly[4] = parent.parent.document.getElementById("gal5").value; //copies the user buyer to index.html hidden field 

	if(what.checked = true) {
		for(var i=0; i<oreilly.length; i++){
			oreilly[i].value = what.value;
		}
	}
}

function openpopup(){
	var oreilly = new Array(); //to hold the answer from the user	
	
	oreilly[0] = parent.parent.document.getElementById("gal1").value;/*parent.parent.document.getElementById("gal1").value;*/ //copies the user buyer to index.html hidden field  
	oreilly[1] = parent.parent.document.getElementById("gal2").value; //copies the user buyer to index.html hidden field  
	oreilly[2] = parent.parent.document.getElementById("gal3").value; //copies the user buyer to index.html hidden field  
	oreilly[3] = parent.parent.document.getElementById("gal4").value; //copies the user buyer to index.html hidden field  		
	oreilly[4] = parent.parent.document.getElementById("gal5").value; //copies the user buyer to index.html hidden field 	
	var newwindow1 = window.open("../orderform.html", "polar_bear", "width=450, height=420");	
	var tmp = newwindow1.document;
	for(var i=0; i<oreilly.length; i++){
		tmp.write(oreilly[i]);
	}
}

createorder();
is used in the button as an onclick an is to test the checkboxes in the same page.
storeValue(what) is what you mentioned above curtis it's storing to the index page (parent.parent.).

I have a popup page in the same directory of the index and I want to write in the popup whatever is stored in the hidden fields.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hidden values problem gilgalbiblewhee Programming and Scripting 0 06-05-2007 10:24 PM
Empty values r sent to the database! dragon Programming and Scripting 0 10-06-2006 11:33 AM
Setting Values For Form Elements With Unconventional Names curtiss Programming and Scripting 2 06-04-2006 08:28 PM
Extracting Single Values From CSS Definitions? curtiss Programming and Scripting 2 01-25-2006 04:52 PM
Really Hidden Form Fields curtiss Programming and Scripting 3 08-15-2005 04:26 PM


All times are GMT -5. The time now is 09:50 PM.

 
KickApps
Clicky Web Analytics


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter