power problem(battery)

I am using two arduinos and one solenoid valve(12v) . how can I power them with battery.

I also want a way to charge my battery

With a 12V battery, you can power the solenoid.
The 12V can be used for the dc jac plug for the Arduino, but you can also use a dc-dc converter.

how can i charge the battery and still get 12v for the soleniod

It depends on the battery type: not all batteries recharge the same way.

As an example LiPO and LiIon batteries are split into cells, each cell providing about 3.7V average. You can put foure of them in series to achieve a 14.1V which you can then step down to 12V for your solenoid, but charging them is not that trivial as you have to balance each cell charge.

Identify the battery type first, then you can think about the charging circuit. I'm new myself to battery power, but I found the Sparkfun and Adafruit tutorials very useful

So I am using two li ion batteries 7.4v each that is 14.8v and regulate it to 12v for solenoid and 9v for arduino(for smooth functioning).
My question is How can I charge them inside a closed box

If you mean wirelessly, good luck. You can do it inductively, but is expensive and complicated.

If you mean wired, I'd drill a hole in the box and feed wires through, or install a jack to the box (or mount your PCBs on the edge so the jack is mounted to the hole).

its with wire .but how to do it . can i just provide direct voltage from the adapter or i need to buy charger.
and how should i connect them so i can use it to

i am using these batteries

Pretty sure you need a charger like this. It controls the current going into the batteries and monitors the voltage so they don't charge too fast or overcharge.

You should consult with Sparkfun to be sure.
I don't know if will do two packs in series - may have add a switch or two so you can charge one and then the other.

but this is to big i want to putr every thing inside a enclosed box

You'll need to work out how to charge it inside the box then. You could maybe plug the charger in instead of a wall-wart, but that means if you lose the charger, you can't recharge it.

You can also look on pololu.com for step-up regulators. Those will allow you to convert lower voltages into higher ones, especially for battery applications.

This is often why its a good idea to define and plan out everything, making sure everything is available or possible before buying materials.

so i think i should only use battery for soleniod does any know long they can power the soleniod
soleniod-12V Solenoid Valve - 3/4" - ROB-10456 - SparkFun Electronics
battery-Polymer Lithium Ion Battery - 500mAh 7.4v - PRT-10500 - SparkFun Electronics

i am gona power both arduino through one adapter 9v