<!DOCTYPE html> <html lang="eb"> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css" /> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> </div> </nav> <div class="col-md-6 well"> <hr style="border-top:1px dotted #ccc;"/> <div class="col-md-8"> <br /> <div class="form-inline"> <input class="form-control" type="number" id="width"/> <input class="form-control" type="number" id="height"/> </div> <br /> <button class="btn btn-primary" onclick="resize();">Resize</buttom> </div> </div> </body> </html>
function resize(){ var height=document.getElementById('height').value; var width=document.getElementById('width').value; if(height=="" || width==""){ alert("Please complete the required field!"); }else{ document.getElementById('image').style.width=width+"px"; document.getElementById('image').style.height=height+"px"; } }