It can be done for both Vista or XP (despite what Microsoft says): however, you need to have a system with BIOS and a motherboard that support USB booting for starters. Then, assuming it is possible from a system perspective (the issue is essentially keeping the USB ports continuously active so you don't lose connection with the USB drive) the procedures are
extremely complicated. Finally, you do ultimately need to install the OS from a computer with a working CD/DVD drive (though I suppose the installation could be done with a flash USB drive if you wanted to add that complexity to the equation). Another thing is that this configuration is completely unsupported (almost nobody will be able to help you with it so you will be on your own) and there are some aspects and programs that may not properly function even if you do everything right (I've read this may apply to Windows Updates but can't confirm that). Also, you should backup the computer you are using to do this (and create a restore point and backup the registry) and you should be prepared to need to completely re-install the system because what you will be doing is very unconventional and the slightest error or the smallest problem with any part of it could cause your system to crash.
From what I've read, you need a working computer to do this so your current situation won't permit it (but if you want it on your computer, you need to install a working OS on it to get this to work (and confirm it is configured and designed to work as described in the various instructions)). THIS MUST BE SETUP ON THE COMPUTER YOU INTEND TO USE THE BOOTABLE USB EXTERNAL DRIVE WITH - THE USB EXTERNAL DRIVE WILL NOT BOOT TO ANY OTHER COMPUTER. You cannot set this up on another machine and then plug it into your machine and expect it to work because it won't. Let me add that
even I would not attempt this from what I've read - it's simply too complicated and risky and other solutions (like just replacing the DVD Drive in your computer - which you'll probably need to do anyway along with installing an OS on it as well) are much better and safer and less likely to cause you problems (and I suspect this will cause problems of one sort or another more frequently than you will want - and again, almost nobody will be able to help because almost nobody knows how to do this or how it works or how to fix problems with it since it isn't even supposed to be possible). And it will work
only on that computer you set it up to work on - you can't go to any computer you want and boot up to the external drive - be sure you're clear about that. I hesitate even providing this information as it is extremely advanced and unsupported and risky, but the decision and the risk is entirely yours.
Here are some articles and threads you need to review to do this if it is possible (some for Vista and some for XP and some apply to both but no one article covers both situations and there is some overlap as I'm including some articles referenced in other articles - and in some cases you need to go to other links for further information but I'm not including those links here as they are in the articles I am including). There's no set order - but most contain at least something of value no matter which OS you are choosing (though the ones for the specific OS are obviously more targeted):
How to Install XP on an External Hard Drive | eHow.com
Vista external USB boot | Coffeehouse | Channel 9 (essentially the post by Corsair)
Ngine.de - How to install and run a FULL Windows XP from a USB drive
ned Productions - Moving an existing Windows installation to a Removable USB drive
XP booting direct from USB - The CD Forum
Let me say again,
I do not recommend that you do this. Find a more normal solution to your problem. Although these procedures suggest it is possible, I do not trust them completely and there are simpler and better alternatives. Besides, you pretty much need to fix your computer to even do this anyway (because as I said
it works on the computer it is setup on and no other). This is
NOT the way to resolve your situation (but I believe it does answer your question).
I hope this helps and that you decide to abandon this idea and just fix your computer normally and use the external drive for simple data storage and/or backups.
If you need to use a USB Flash/Thumb Drive
just to install the OS (as opposed to running it), then check out:
http://www.vistax64.com/tutorials/181538-usb-bootable-vista-installation-flash-thumb-drive.html
Good luck!