Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    79
    Thanks
    2
    Thanked 1 Time in 1 Post

    a text variable referred to in javascript not present on the screen

    The answer is probably trivial.

    Code:
    function VER5DN(){
    //
    n=n-1;if (n<1){n=b-1}	
    if(klass[n]==null){n=0};x=klass[n];v=new Array;x=x+"|";i=0;while(x.length>1){l=x.substring(0,x.indexOf("|"));v[i]=l;i++;x=x.substring(x.indexOf("|")+1)};
    
    document.klass.VERFOR5_3.value=v[3];
    The last line in the code assigns a variable used in html to the outcome of the above readout from an array.

    All works well, until I remove an input field from the html layout of the website. so as long as this field exists

    Code:
         <form name="klass">
    
      <fieldset>
        <legend>VERFOR</legend>
    <table border="1" cellspacing="3" cellpadding="3">
      <tr>
        <td>      <input type="button" value=" UP " 
                  
                  onClick="VER1DN()">
          <input type="TEXT" name="VERFOR5_3" size="20" >

    , the code works.

    Since there are more of these fields and they mess up the layout of the site, I would like to somehow get rid of the variable being manifest on the page. But then the code stops working.

    What is a more elegant way to make the variable exist in the html, without taking it to the screen?
    Last edited by eydg; 11-03-2012 at 09:56 PM.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    For example <input type="hidden" name="VERFOR5_3" />. This way the field will still be part of the form and will also be transmitted on submit.

  • #3
    New Coder
    Join Date
    Sep 2012
    Posts
    79
    Thanks
    2
    Thanked 1 Time in 1 Post
    works great. thank you.


  •  

    Posting Permissions

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