0

I have a function that returns a value that I would like to set as the value in and <input> statement.

So essentially I have a javascript function deCols() that returns a value and I would like to do something like <input type='hidden' id='devCols' name='devCols' value=devCols() />
which of course doesn't work.

Any help would be appreciated.

Thanks/Hal

2
Contributors
8
Replies
26
Views
4 Years
Discussion Span
Last Post by hlamster
0

So essentially I have a javascript function deCols() that returns a value and I would like to do something like <input type='hidden' id='devCols' name='devCols' value=devCols() /> which of course doesn't work.

@hlamster

What are you trying to do? I got no clue what you are doing?

<input type='hidden' id='devCols' name='devCols' value=devCols() />

You have a devCols() function but where is the javascript code?

0
<script language='javascript' type='text/javascript'>
var details=0;
function detailCols()
{
  details=0;
  var table = document.getElementById('fullTable');
  var rows = table.getElementsByTagName("tr");
  for(var i=0;i<rows.length;i++)
  {
    var cells = rows[i].getElementsByTagName("th");
    var cols = cells.length;
    if(cols < 1) continue;
    for (var j=0; j<cols; j++)
    {      
      if(cells[j].className == 'moreDetailInc')
      {
        if(cells[j].style.display == 'table-cell') details = details || 1;
      }
      if(cells[j].className == 'moreDetailExp')
      {
        if(cells[j].style.display == 'table-cell') details = details || 2;
      }
      if(cells[j].className == 'moreDetailAss')
      {
        if(cells[j].style.display == 'table-cell') details = details || 4;
      }
    }
}
0

@hlamster

What did you post? I don't think we are on the same page. You mention you want to understand how the devCols() function works in <input> tags but you post a code not even related at all.

Where is your devCols() function?

You post a detailCols() function:

function detailCols()

Edited by LastMitch

0

Sorry - changed the name of the function..... Sorry that I am being so sloppy.

I have a page that has columns of a table that can be hidden or shown (there is javascript code that does this quite nicely). What I need to do is to pass to another page (that prints the form) with an <input> variable that tells which columns the user has shown. The detailCols() function sets the var details to a value that indicates which of the column sets is being shown. (Note there is a bug in the above code the || statments should be just |. Again - sorry for my sloppiness. I have been wrestling with this for awhile and am getting sloppy.

I am trying to get the output of that function to be passed posted in a form to be passed to another page. The output of the var details needs to be put in a form <input... > statment. I invoke the routine detailCols on the submit button for the form. I tried using a document.write to generate the <input> statement but that didn't seem to work. Any suggestions would be most appreciated.

Thanks/Hal

0

What I need to do is to pass to another page (that prints the form) with an <input> variable that tells which columns the user has shown.

@hlamster

I still don't quite understand what you are doing?

So you want to pass a valve to another page from a form submit? Am I correct?

The has valve has to appear on the <input> tags?

The javascript you provided has table format but you want the valve from the table format to appear on the <input> tags?

0

Yes, I need to get the value to appear in the <input> tag.

Thanks/hal

0

Yes, I need to get the value to appear in the <input> tag.

@hlamster

I don't understand what you are trying to do? If this is a form, then it will make sense but I don't know.

You mean something like:

<form>
<input type='hidden' id='moreDetailInc' name='moreDetailInc' value="" />
<input type='hidden' id='moreDetailExp' name='moreDetailExp' value="" /> 
<input type='hidden' id='moreDetailAss' name='moreDetailAss' value="" /> 
<input type="submit" value="submit"/>
<form>

You know you never did provide a form?

0
   <form action='print_plan.php' method='post' name='printplan' target='_blank'>
   <input type='hidden' id='PlanNo' name='PlanNo' value='$PlanNo' />   
   <input type='hidden' id='IDuser' name='IDuser' value='$IDuser' />
   <script language='javascript' type='text/javascript'>
   document.write(\"<input type='hidden' id='detCols' name='detCols' value='\",details,\"' />\")
   </script>
   <input name='Submit' type='image' value='print' title='Print Plan'  src='images/print.gif'
           alt='Print Plan' onclick='detailCols()' />
   </form>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.