[eluser]Aken[/eluser]
set_value() is more than just a shortcut - because it checks for existing values, replaces it with any updated values, and allows you to set a default if none exists in the first place.
Because you're using Javascript (a client-side language) to create the element, there's no way to use the set_value() function along with it.
What I'd recommend is to generate the text box in your HTML along with everything else, but keep it hidden and only show it with Javascript instead of generating it completely. You'll have to make sure to use/ignore the value when appropriate, of course.
What Andreas recommended will also work, just not how I'd go about it. Up to you, though!