Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable in a variable

Status
Not open for further replies.

WebRic

Technical User
Sep 21, 2004
95
0
0
GB
Hi,

I'm sruggling to figure out how to write this bit of code (below). Depending on which radio button is click I want a number to be passed to here: addressr.value

Code:
<script language="JavaScript" type="text/JavaScript">
	function updateaddress(addressr) {
var formObj = document.forms['register'];
	    formObj.PSAddress1.value = formObj.addressline1 + addressr.value +.value;
		formObj.PSAddress2.value = formObj.addressline2 + addressr.value +.value;
		formObj.PSCity.value = formObj.posttown + addressr.value +.value;
		formObj.PSCounty.value = formObj.postcode + addressr.value +.value;
		formObj.LocalAuth.value = formObj.district + addressr.value +.value;
	}

</script>


<div  class="oddrow" onMouseOver="this.className='highlightrow'" onMouseOut="this.className='oddrow'">
		<input type="radio" name="selectaddress" id="selectaddress1" value="1" onClick="updateaddress(this)" />  		
		37B High Street, London, se1 abc
        <input type="hidden" name="addressline11" id="addressline11" value="37 High Street" />  
        <input type="hidden" name="addressline21" id="addressline21" value="" />  
        <input type="hidden" name="posttown1" id="posttown1" value="London" />  
        <input type="hidden" name="postcode1" id="postcode1" value="se1 abc" />  
        <input type="hidden" name="district1" id="district1" value="london" />  
</div>			

<div  class="evenrow" onMouseOver="this.className='highlightrow'" onMouseOut="this.className='evenrow'">
		<input type="radio" name="selectaddress" id="selectaddress2" value="2" onClick="updateaddress(this)" />  		
		37B High Street, London, se1 abc
        <input type="hidden" name="addressline12" id="addressline12" value="37b High Street" />  
        <input type="hidden" name="addressline22" id="addressline22" value="" />  
        <input type="hidden" name="posttown2" id="posttown2" value="London" />  
        <input type="hidden" name="postcode2" id="postcode2" value="se1 abc" />  
        <input type="hidden" name="district2" id="district2" value="london" />  
</div>

Any ideas?
 
figured out how to do this now. Using eval()
Thanks,

R
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top