November 24, 2010

how to pop a dialog box on button click

Question by shalu

Hello Friends
I want to upload a image but according to requirement when click on button a pop window display and inner part of pop window display browse field using code something like

<form action="index.php" method="post" onsubmit="">
    <div><label>Name:</label> <input type="text" name="form[name]" /></div>
    <div><label>File:</label> <input type="file" name="form[file]" /></div>
    <div><input type="submit" value="SUBMIT" /></div>
</form>

actually i want to show this browse field in pop-up window.
Please reply me regard this
Thanks

Answer by Starx

Just give a myform ID to your form hide it, using display:none; and try this code

<a href="#" onClick="document.getElementById('myform').style.display='';">Show Browse</a>

UPDATE

I have created a demo of what you wanted. Check it here http://jsfiddle.net/Starx/rVw9M/

Since you are unfamilier with jquery, you need jquery library for this to run put this in your head (HTML Pages’ Head :D)

<script type='text/javascript' src='http://code.jquery.com/jquery-1.4.4.min.js'></script>

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!