Ahmed
I'm also not clear what you're trying to do (a full example would be best), but hopefully this will help.
<jsxgraph width="500" aspect-ratio="3/2">
var brd = JXG.JSXGraph.initBoard('jxbox', {boundingbox:[-5,5,5,-5], axis:true});
var p = brd.create('point', [1,2]);
</jsxgraph>
So you already have a built-in facility for creating the board size with the desired aspect ratio.
A suggestion, though. The default Moodle setup is not phone-friendly. It would be much better to specify max-width="500" rather than "width". It means the graph will show successfully on a phone with nothing disappearing off the edge.
Anyway, within Moodle, that answers your main query, "Changing the width parameter 500 to be dependent on the height".
I'm guessing from your later question that you want to change the bounding box after a user has entered an equation. For example, if they wanted to see the graph of y = sin(x), you probably wouldn't want the upper and lower y-values to be 5 and -5, better would be, say, 1.5 or 2. Is that what you mean?
That's where you would use Alfred's suggestion of board.setBoundingBox([-20,20,20,-20], true); but in this case it would be board.setBoundingBox([-5,2,5,-2], true);
Regards
Murray