0

How to make this same form by clicking the submit button, you send the same form to another php by POST method form where the inputs type text appear filled and the select will be select with the same option selected that the first form. I hope understand my explanation.

HTML

<form id="formPOST" action="pr01post.php" method="POST" >
        Nombre<input type="text" id="txtNombre" name="txtNombre"/><br>
        Edad<input type="text" id="txtEdad" name="txtEdad"/><br>
        Provincia<select id="selProv" name="selProv">
                    <option value='0'>Seleccione una provincia</option>
                    <option value='1'>Álava</option>
                    <option value='2'>Albacete</option>
                    <option value='3'>Alicante/Alacant</option> 
                 </select><br>
        Fec. Nac.:<input type="text" id="txtFecNac" name="txtFecNac"/><br>
        Sexo: Hombre<input type="radio" name="radSex" value="Varón" checked>Mujer<input type="radio" name="radSex" value="Mujer">
        <input type="submit" name="subEnv" />          
    </form>
2
  • is it posible do it without to use jquery? Commented Mar 20, 2013 at 18:55
  • 2
    You use PHP to pre-fill in the form based on the inputs, then spit out the same form. Commented Mar 20, 2013 at 18:55

1 Answer 1

0

Use the power of jQuery, Luke!

<script type="text/javascript">
    $(document).ready(function() {
        $('#selProv option[value="<?=$_POST['selProv'];?>"]').attr('selected','selected');
    });
</script>

And be sure you've included actual jquery lib on your page. Can do it like this:

<script src="http://code.jquery.com/jquery-1.9.1.js" ></script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.