Describing non-vanishing $1$-forms on two dimensional manifolds. Let $h_1 \mathrm{d}x_1 + h_2 \mathrm{d}x_2$ be a non-vanishing $1$-form on a $2$-dimensional manifold. Why do locally exist smooth functions $f,g$ with $f\mathrm{d}g= h_1 \mathrm{d}x_1 + h_2 \mathrm{d}x_2$? 
I think this should follow from some statement about differential equations (and existence of some integrating factor?) in usual analysis, but sadly in all of mathematics differential equations are probably the topic I know the least about.
Edit: It would suffice to prove the following: let $h_1, h_2: \mathbb{R}^2 \rightarrow \mathbb{R}$ be smooth functions. Then exists for all $x \in \mathbb{R}^2$ a neighborhood $U$ and $f,g_1, g_2$ smooth functions on $U$, such that $h_i=f g_i$ and $\partial_{x_1}g_2= \partial_{x_2}g_1$.
 A: Do you know the Frobenius theorem? Let $\omega=h_1dx_1+h_2dx_2$, at each point $p\in M$ the equation $\omega=0$ defines a 1-dimensional subspace (a line) of the tangent space $T_pM$, which defines a distribution. Then if $\omega$ satisfies the Frobenius conditon, that is, if there exists a 1-form $\sigma$ such that $d\omega=\sigma\wedge\omega$, the distribution is integrable. That is, there exists a function $g$ such that the equation $dg=0$ defines the same subspaces. Thus $\omega(X)=0$ if and only if $dg(X)=0$, hence $\omega=fdg$.
Note For 1-forms they always satisfy the condition: assume $d\omega=Fdx_1\wedge dx_2$, just let $\sigma=\frac{F(h_2dx_1-h_1dx_2)}{h_1^2+h_2^2}$ we will have $\sigma\wedge\omega=d\omega$. So we get the conclusion.
Geometrically it is obvious: $\omega(X)=0$ defines a subspace (line) at each point. If these lines are integrable, there exists a flow $\Phi: \mathbb{R}\times M\rightarrow M$ such that the tangent vector $\dot\Phi_p(0)$ of the curve $\Phi_p(t)=\Phi(t,p)$ lies on $X$. 
Suppose $\omega=fdg$, then $\omega(X)=0$ implies $dg(X)=0$, that is, the gradient of $g$ is perpendicular to $X$ at each point. Choose a curve $c$ such that $c=c(s)$ intersects the flow perpendicularly and $c(0)=p$, then $s, t$ defines a local coordinate chart. The function $g=s$ has the desired property.
