The IRF540's maximum specified Gate leakage is 100nA at 25°c, so theoretically you could use up to 1 Meg (for voltage drop of 0.1V or less). However leakage current increases with temperature, and such a high resistance could make the Gate quite sensitive to noise.
Use the lowest value that meets your safety requirements. Anything up to 10k should be fine.
That circuit is designed to provide fast switching when driven by a voltage that may exceed the FET's Gate voltage rating.
Since the IRFB4310's Gate is rated for +-20V and the IR2184 is rated for 20V max, most of the parts in that circuit are redundant. Just put a single resistor in series with the Gate, large enough to limit current spikes and damp out any ringing that might otherwise occur.
The diode in parallel with the output is not necessary, but helps to reduce dissipation in the FET when PWM is applied. If you do use one then make it a Schottky type, as this has lower voltage drop so current will flow through it rather than the FET's internal body diode.
The IRFB4310 is rated for 100V max Vdss, which is overkill for a 24V supply. A lower voltage FET may have lower resistance and capacitance, for example the IRFB7440 is rated at 40V and has Rdson = 0.0025Ω and Qg = 110nC at 12V, twice as good as the IRFB4310.
Best Answer
This question have been asked too many times , i will try to guide you to on what to search for :
It poses a challenge since you need to create 5v or 12v on Vgs not with respect to ground which can means the gate to ground voltagge is higher than supply voltage .
Solutions for this problem
a-you either use a P-channel mosfet
b-use some kind of high side driver ( isolated /floating supply , transformer coupled drive, bootstrap , charge pump ) , there is literally thousands of articles on the internet regarding this subject and too many ICs and solutions.