We help IT Professionals succeed at work.

Increasing the length of a var in a javascript function

keithwilson1
keithwilson1 asked
on
I need the length of the variable 'abbr' increased to 45 because it is being truncated when being display on the website textbox control.

<script language="javascript" type="text/javascript">

function doSubmit()
{
      cidabbr = document.frmAddCertification.CertificationId.options(frmAddCertification.CertificationId.selectedIndex).value;
      
      if (cidabbr.length > 0)
      {
          cidabbr = cidabbr.split('||')
          cId=cidabbr[0];
           abbr=cidabbr[1];
          //alert(cId);
          //alert(abbr);
          initVal = window.opener.frmTransferRequest.RequestCertifications.value;
          //alert(initVal);
          window.opener.frmTransferRequest.RequestCertifications.value = initVal + ' ' + abbr + ',';
          //alert(window.opener.frmTransferRequest.RequestCertifications.value);
          self.close();
      }
}
                              
</script>
Comment
Watch Question

Top Expert 2011

Commented:
Do you want to just change this line:
abbr=cidabbr[1];

Open in new window


to this?
abbr=45;

Open in new window

keithwilson1developer

Author

Commented:
I want 'abbr' to receive the value of 'cidabbr[1] but increase the size of 'abbr' from 30 to 45 to be able to display the full description that is being passed to it.
keithwilson1developer

Author

Commented:
the value passed to abbr is 'English Technology and Science' but when the value is moved to my display field it is 'english Technology and Scien'.
Top Expert 2011
Commented:
The value for "abbr" is whatever you want it to be.  It's length is determined by the value.

e.g.,
if abbr="1234567890", its length is 10.
if abbr="12345678901234567890", its length is 20.
if abbr="123456789012345678901234567890", its length is 30.
etc.

When you say the value is truncated, do you mean it is literally truncated,
e.g., abbr="12345678901234567890" but on your opener form only "123456789012345" makes it into the form?

or is it a display issue, where the form field is not wide enough for the user to see all of it?

In either case, what are the attributes of the RequestCertifications field?
It sounds like either "size" or "max-length" might be to blame.
http://www.tizag.com/htmlT/htmltextfields.php