do while loops

Results 1 to 2 of 2

Thread: do while loops

  1. #1
    Join Date
    Dec 1969

    Default do while loops

    Hi, I am trying to run a loop that reads a text field&#039s value, and then adds spaces to the end of the string.<BR>EX:<BR>the value of my City is "LA", I want to add the state "CA" to the end of the field to make 1 value. The length of CITYSTATE is 20. So the length of CITY is 2. I want to add 16 spaces. That gives me a length of 18. Then add the State of 2 which gives me the length of 20. It should work the same for any City, if it is Boston, then that length would be 6 + 12 spaces + State. This would enter into my DB like (LA CA)or(Boston MA).<BR>Does anyone know a way to do this. Thanks.

  2. #2
    Thiago Lessa Guest

    Default RE: do while loops

    I didn´t understand what you wanted to mean and I don´t Know if it is going to work but I think I have something for you...Try something like this:<BR> &#060;input type="text" name="t1"... onchange="validate(t1)"<BR>&#060;script&#062;<BR>f unction validate(obj)<BR>{<BR>var brasil = 0; //It would be better to set the variables <BR>var total; // in the &#060;head&#062; to optmize the speed<BR>var comp = obj.length;<BR>var max = 20;<BR> if (obj.length &#060; max)<BR> {<BR> total = max - comp;<BR> for (i=0;i &#060; total;i++)<BR> brasil = brasil + &#060;&nbsp&#062;<BR> } <BR> obj = obj + brasil;<BR> return obj;<BR>}<BR>&#060;/script&#062;<BR>Well, sincerely you may have to change a lot of things,but the idea is something like that.I forgot many things conceraning javascript,moreover I did this very quickly so It must have many bugs that you will find easy to correct. I hope I have added you in something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts