Here's sketch how to construct such a function: Let's start by defining f on Q (the rational numbers) by first splitting Q into countable number of disjoint dense subsets A_n of R (e.g. look at reduced fractions whose denominators are of the form p^k for some prime p, for fixed p every such set is dense and for different p's they are disjoint). As rationals themselves are countable, we may then set f(x) = q_n for all x in A_n, where q_n is an enumeration fo the rationals.
This construction already gives us a function such that every interval (x_1, x_2) contains a point x such that f(x) = y for every rational number y.
Now, in a similar way we may consider a set of the form s + Q where s is an irrational number. Setting f(x) = s + q_n for all x in s + A_n, we get a function which also attains all numbers of the form y = s + q for some rational q on every interval.
Finally, let's say that two real numbers s and t are equivalent if they differ by a rational number. By the axiom of choice we can choose a representative from every equivalence class, so that for every two representatives s and t the sets s + Q and t + Q are disjoint. Using the above construction for every representative lets you define a function with the property you wanted.
This construction already gives us a function such that every interval (x_1, x_2) contains a point x such that f(x) = y for every rational number y.
Now, in a similar way we may consider a set of the form s + Q where s is an irrational number. Setting f(x) = s + q_n for all x in s + A_n, we get a function which also attains all numbers of the form y = s + q for some rational q on every interval.
Finally, let's say that two real numbers s and t are equivalent if they differ by a rational number. By the axiom of choice we can choose a representative from every equivalence class, so that for every two representatives s and t the sets s + Q and t + Q are disjoint. Using the above construction for every representative lets you define a function with the property you wanted.