Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two <TD>'s in a Table.
I try to get them resized when I drag a input type "range". So I have added a onChange, like so:

<input type="range" name="memberarea" min="64" max="960" VALUE='220' onchange="resize_memeberarea()">
<input type="range" name="mainfield" min="64" max="1216" VALUE='640' onchange="resize_mainfield()">

.. and then I have added a script like this:

<script>
function resize_memeberarea() {
  var x = document.getElementById("$_SESSION['memberarea']").value;
  document.getElementById("memberarea").innerHTML = x;

  function resize_mainfield() {
    var y = document.getElementById("$_SESSION['mainfield']").value;
    document.getElementById("mainfield").innerHTML = y;
  }
}
</script>

I want the <TD>'s to be resized as I move the slider, in real time. So I use the "onChange". 
I have the width of the <TD> set to $_SESSION['memberarea'] that contains the value.

Can someone please help me to get this solved. 
Thanks!

/Jacob


What I have tried:

<script>
function resize_memeberarea() {
  var x = document.getElementById("$_SESSION['memberarea']").value;
  document.getElementById("memberarea").innerHTML = x;

  function resize_mainfield() {
    var y = document.getElementById("$_SESSION['mainfield']").value;
    document.getElementById("mainfield").innerHTML = y;
  }
}
</script>
Posted
Updated 29-Mar-19 0:07am

1 solution

Not clear what the function suppose to do, but the syntax seem a little off. Here is an example: cp_js_currying - JSFiddle[^] with correct syntax. The second onchange should call resize_memeberarea()() instead of resize_memeberarea() because it trying to access the child function.


Reference:
Can you write nested functions in JavaScript? - Stack Overflow[^]
 
Share this answer
 
v2
Comments
Member 13793536 29-Mar-19 8:05am    
Hello and thanks you for you answer.
Maybe it will be easier to tell you what I am trying to do.

I want to resize two TD's in a tabel when dragging two 'range' form input types. One for each TD. I think that I need to use the onChange event, as I want the to resize "live". But I have no clue about how I do this.

Can you guide me on the way..
Bryian Tan 1-Apr-19 8:27am    
You want to share some HTML markup?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900