You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "semaj.najraham" <se...@hotmail.com> on 2007/08/02 17:42:41 UTC

Using Nested tag and JavaScript

Hey guys,

I need some help using nested tag library and javascript.  I have an
actionForm named RegistrationForm that has two AddressForm; mailing and
billing addresses. I need to implement a requirement if a user clicks a
checkbox say 'same as mailing', I need to copy the textfield values from
mailing address to billing address.

I can easily use the javascript something like this:

function copyMailingAddress {
 if (document.forms[0].copyMailCB.checked)
 {
   document.forms[0].billingLine1.value =
document.forms[0].mailingLine1.value;
   .........
  }
}

The only problem I'm having is to use it with nested tag library.
In my jsp, I have following code

<nested:nest property="mailingAddress">
 <nested:text property="line1" />
 <nested:text property="line2" />
 .....
</nested:nest>

Similarly,

<nested:nest property="billingAddress">
 <nested:text property="line1" />
 <nested:text property="line2" />
 .....
</nested:nest>

When this jsp is rendered as html, the code will something like this:
<input type="text" name="mailingAddress.line1" value="">
<input type="text" name="mailingAddress.line2" value="">

<input type="text" name="billingAddress.line1" value="">
<input type="text" name="billingAddress.line2" value="">

Now how can I copy the values from mailingAddress to billingAddress using
above JavaScript? The dot in between name prevents to execute the above
javascript...

Could anybody point me how I can resolve this problem?

Thank you,
semaj
-- 
View this message in context: http://www.nabble.com/Using-Nested-tag-and-JavaScript-tf4206847.html#a11966912
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Using Nested tag and JavaScript

Posted by Jasper Floor <ja...@gmail.com>.
On 8/3/07, semaj.najraham <se...@hotmail.com> wrote:
>
> Guys.. any ideas??

Hi, I have never used this so I don't really know what I 'm talking
about, but can't you use the onclick attribute of the nested tag to
give it a javascript to execute?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Using Nested tag and JavaScript

Posted by "semaj.najraham" <se...@hotmail.com>.
Guys.. any ideas??

semaj.najraham wrote:
> 
> Hey guys,
> 
> I need some help using nested tag library and javascript.  I have an
> actionForm named RegistrationForm that has two AddressForm; mailing and
> billing addresses. I need to implement a requirement if a user clicks a
> checkbox say 'same as mailing', I need to copy the textfield values from
> mailing address to billing address.
> 
> I can easily use the javascript something like this:
> 
> function copyMailingAddress {
>  if (document.forms[0].copyMailCB.checked)
>  {
>    document.forms[0].billingLine1.value =
> document.forms[0].mailingLine1.value;
>    .........
>   }
> }
> 
> The only problem I'm having is to use it with nested tag library.
> In my jsp, I have following code
> 
> <nested:nest property="mailingAddress">
>  <nested:text property="line1" />
>  <nested:text property="line2" />
>  .....
> </nested:nest>
> 
> Similarly,
> 
> <nested:nest property="billingAddress">
>  <nested:text property="line1" />
>  <nested:text property="line2" />
>  .....
> </nested:nest>
> 
> When this jsp is rendered as html, the code will something like this:
> <input type="text" name="mailingAddress.line1" value="">
> <input type="text" name="mailingAddress.line2" value="">
> 
> <input type="text" name="billingAddress.line1" value="">
> <input type="text" name="billingAddress.line2" value="">
> 
> Now how can I copy the values from mailingAddress to billingAddress using
> above JavaScript? The dot in between name prevents to execute the above
> javascript...
> 
> Could anybody point me how I can resolve this problem?
> 
> Thank you,
> semaj
> 

-- 
View this message in context: http://www.nabble.com/Using-Nested-tag-and-JavaScript-tf4206847.html#a11983611
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Using Nested tag and JavaScript

Posted by "semaj.najraham" <se...@hotmail.com>.
It works now..

Thanks..


semaj.najraham wrote:
> 
> Hi Paul,
> 
> I successfully copied the values from mailing address textfields to
> billing address textfields using javascript (see below). However, the
> billing address text fields values are not sent to the server. They are
> empty!!
> 
> If I directly type mailing and billing address, the values are sent to the
> server. Am I missing something?
> 
> This is what I did in javascript:
> 
> <script language="JavaScript">
> var billLine1=document.getElementById('billLine1');
> var billLine2=document.getElementById('billLine2');
> var billCity=document.getElementById('billCity');
> var billState=document.getElementById('billState');
> var billZip=document.getElementById('billZip');
> 
> var mailLine1=document.getElementById('mailLine1');
> var mailLine2=document.getElementById('mailLine2');
> var mailCity=document.getElementById('mailCity');
> var mailState=document.getElementById('mailState');
> var mailZip=document.getElementById('mailZip');
> 
> var copyCheckbox=document.getElementById('copyMailCheckbox');
> 
> function copyMailingAddress() 
> {
> 	if (copyCheckbox.checked)
> 	{
> 		billLine1.value=mailLine1.value;
> 		billLine2.value=mailLine2.value;
> 		billCity.value=mailCity.value;
> 		billState.value=mailState.value;
> 		billZip.value=mailZip.value;
> 		
> 	}
> 	else 
> 	{
> 		billLine1.value='';
> 		billLine2.value='';
> 		billCity.value='';
> 		billState.value='';
> 		billZip.value='';
> 				
> 	}
> 	
> }
> 
> Thanks,
> semaj
> 
> 
> 
> Paul Benedict-2 wrote:
>> 
>> Attach styleId to your fields. Then you can use JavaScript to manipulate 
>> form fields by their id. use getElementById scripting method.
>> 
>> semaj.najraham wrote:
>>> Hey guys,
>>>
>>> I need some help using nested tag library and javascript.  I have an
>>> actionForm named RegistrationForm that has two AddressForm; mailing and
>>> billing addresses. I need to implement a requirement if a user clicks a
>>> checkbox say 'same as mailing', I need to copy the textfield values from
>>> mailing address to billing address.
>>>
>>> I can easily use the javascript something like this:
>>>
>>> function copyMailingAddress {
>>>  if (document.forms[0].copyMailCB.checked)
>>>  {
>>>    document.forms[0].billingLine1.value =
>>> document.forms[0].mailingLine1.value;
>>>    .........
>>>   }
>>> }
>>>
>>> The only problem I'm having is to use it with nested tag library.
>>> In my jsp, I have following code
>>>
>>> <nested:nest property="mailingAddress">
>>>  <nested:text property="line1" />
>>>  <nested:text property="line2" />
>>>  .....
>>> </nested:nest>
>>>
>>> Similarly,
>>>
>>> <nested:nest property="billingAddress">
>>>  <nested:text property="line1" />
>>>  <nested:text property="line2" />
>>>  .....
>>> </nested:nest>
>>>
>>> When this jsp is rendered as html, the code will something like this:
>>> <input type="text" name="mailingAddress.line1" value="">
>>> <input type="text" name="mailingAddress.line2" value="">
>>>
>>> <input type="text" name="billingAddress.line1" value="">
>>> <input type="text" name="billingAddress.line2" value="">
>>>
>>> Now how can I copy the values from mailingAddress to billingAddress
>>> using
>>> above JavaScript? The dot in between name prevents to execute the above
>>> javascript...
>>>
>>> Could anybody point me how I can resolve this problem?
>>>
>>> Thank you,
>>> semaj
>>>   
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-Nested-tag-and-JavaScript-tf4206847.html#a12022841
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Using Nested tag and JavaScript

Posted by "semaj.najraham" <se...@hotmail.com>.
Hi Paul,

I successfully copied the values from mailing address textfields to billing
address textfields using javascript (see below). However, the billing
address text fields values are not sent to the server. They are empty!!

If I directly type mailing and billing address, the values are sent to the
server. Am I missing something?

This is what I did in javascript:

<script language="JavaScript">
var billLine1=document.getElementById('billLine1');
var billLine2=document.getElementById('billLine2');
var billCity=document.getElementById('billCity');
var billState=document.getElementById('billState');
var billZip=document.getElementById('billZip');

var mailLine1=document.getElementById('mailLine1');
var mailLine2=document.getElementById('mailLine2');
var mailCity=document.getElementById('mailCity');
var mailState=document.getElementById('mailState');
var mailZip=document.getElementById('mailZip');

var copyCheckbox=document.getElementById('copyMailCheckbox');

function copyMailingAddress() 
{
	if (copyCheckbox.checked)
	{
		billLine1.value=mailLine1.value;
		billLine2.value=mailLine2.value;
		billCity.value=mailCity.value;
		billState.value=mailState.value;
		billZip.value=mailZip.value;
		
	}
	else 
	{
		billLine1.value='';
		billLine2.value='';
		billCity.value='';
		billState.value='';
		billZip.value='';
				
	}
	
}

Thanks,
semaj



Paul Benedict-2 wrote:
> 
> Attach styleId to your fields. Then you can use JavaScript to manipulate 
> form fields by their id. use getElementById scripting method.
> 
> semaj.najraham wrote:
>> Hey guys,
>>
>> I need some help using nested tag library and javascript.  I have an
>> actionForm named RegistrationForm that has two AddressForm; mailing and
>> billing addresses. I need to implement a requirement if a user clicks a
>> checkbox say 'same as mailing', I need to copy the textfield values from
>> mailing address to billing address.
>>
>> I can easily use the javascript something like this:
>>
>> function copyMailingAddress {
>>  if (document.forms[0].copyMailCB.checked)
>>  {
>>    document.forms[0].billingLine1.value =
>> document.forms[0].mailingLine1.value;
>>    .........
>>   }
>> }
>>
>> The only problem I'm having is to use it with nested tag library.
>> In my jsp, I have following code
>>
>> <nested:nest property="mailingAddress">
>>  <nested:text property="line1" />
>>  <nested:text property="line2" />
>>  .....
>> </nested:nest>
>>
>> Similarly,
>>
>> <nested:nest property="billingAddress">
>>  <nested:text property="line1" />
>>  <nested:text property="line2" />
>>  .....
>> </nested:nest>
>>
>> When this jsp is rendered as html, the code will something like this:
>> <input type="text" name="mailingAddress.line1" value="">
>> <input type="text" name="mailingAddress.line2" value="">
>>
>> <input type="text" name="billingAddress.line1" value="">
>> <input type="text" name="billingAddress.line2" value="">
>>
>> Now how can I copy the values from mailingAddress to billingAddress using
>> above JavaScript? The dot in between name prevents to execute the above
>> javascript...
>>
>> Could anybody point me how I can resolve this problem?
>>
>> Thank you,
>> semaj
>>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-Nested-tag-and-JavaScript-tf4206847.html#a12022536
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Using Nested tag and JavaScript

Posted by "semaj.najraham" <se...@hotmail.com>.
Thank you Paul.. you save my day!!


Paul Benedict-2 wrote:
> 
> Attach styleId to your fields. Then you can use JavaScript to manipulate 
> form fields by their id. use getElementById scripting method.
> 
> semaj.najraham wrote:
>> Hey guys,
>>
>> I need some help using nested tag library and javascript.  I have an
>> actionForm named RegistrationForm that has two AddressForm; mailing and
>> billing addresses. I need to implement a requirement if a user clicks a
>> checkbox say 'same as mailing', I need to copy the textfield values from
>> mailing address to billing address.
>>
>> I can easily use the javascript something like this:
>>
>> function copyMailingAddress {
>>  if (document.forms[0].copyMailCB.checked)
>>  {
>>    document.forms[0].billingLine1.value =
>> document.forms[0].mailingLine1.value;
>>    .........
>>   }
>> }
>>
>> The only problem I'm having is to use it with nested tag library.
>> In my jsp, I have following code
>>
>> <nested:nest property="mailingAddress">
>>  <nested:text property="line1" />
>>  <nested:text property="line2" />
>>  .....
>> </nested:nest>
>>
>> Similarly,
>>
>> <nested:nest property="billingAddress">
>>  <nested:text property="line1" />
>>  <nested:text property="line2" />
>>  .....
>> </nested:nest>
>>
>> When this jsp is rendered as html, the code will something like this:
>> <input type="text" name="mailingAddress.line1" value="">
>> <input type="text" name="mailingAddress.line2" value="">
>>
>> <input type="text" name="billingAddress.line1" value="">
>> <input type="text" name="billingAddress.line2" value="">
>>
>> Now how can I copy the values from mailingAddress to billingAddress using
>> above JavaScript? The dot in between name prevents to execute the above
>> javascript...
>>
>> Could anybody point me how I can resolve this problem?
>>
>> Thank you,
>> semaj
>>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-Nested-tag-and-JavaScript-tf4206847.html#a11989393
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Using Nested tag and JavaScript

Posted by Paul Benedict <pb...@apache.org>.
Attach styleId to your fields. Then you can use JavaScript to manipulate 
form fields by their id. use getElementById scripting method.

semaj.najraham wrote:
> Hey guys,
>
> I need some help using nested tag library and javascript.  I have an
> actionForm named RegistrationForm that has two AddressForm; mailing and
> billing addresses. I need to implement a requirement if a user clicks a
> checkbox say 'same as mailing', I need to copy the textfield values from
> mailing address to billing address.
>
> I can easily use the javascript something like this:
>
> function copyMailingAddress {
>  if (document.forms[0].copyMailCB.checked)
>  {
>    document.forms[0].billingLine1.value =
> document.forms[0].mailingLine1.value;
>    .........
>   }
> }
>
> The only problem I'm having is to use it with nested tag library.
> In my jsp, I have following code
>
> <nested:nest property="mailingAddress">
>  <nested:text property="line1" />
>  <nested:text property="line2" />
>  .....
> </nested:nest>
>
> Similarly,
>
> <nested:nest property="billingAddress">
>  <nested:text property="line1" />
>  <nested:text property="line2" />
>  .....
> </nested:nest>
>
> When this jsp is rendered as html, the code will something like this:
> <input type="text" name="mailingAddress.line1" value="">
> <input type="text" name="mailingAddress.line2" value="">
>
> <input type="text" name="billingAddress.line1" value="">
> <input type="text" name="billingAddress.line2" value="">
>
> Now how can I copy the values from mailingAddress to billingAddress using
> above JavaScript? The dot in between name prevents to execute the above
> javascript...
>
> Could anybody point me how I can resolve this problem?
>
> Thank you,
> semaj
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org