开发者

Displaying values from one form in another form on the page before the user clicks the submit button

I am new to php.I want to perform form cascading.

i wil开发者_运维技巧l be having form like registration form,where if i enter any data in text-fields it should be automatically displayed in another form before the submit button is clicked.

Please if anybody knows help me,

I am in need.


A little Javascript will do the trick. It will be easy if you use something like jQuery to help you out. Just bind each field in your form to the change event using the change() method, and then update the "cascaded" field to the value passed to the change() method.

For example, consider the HTML:

<form>
  <input type="text" id="field1" />
  <input type="submit" />
</form>

And supposed you want to update the following div dynamically as the above form is edited:

<div id="field1_val"></div>

Add the following script to the head of your HTML:

//This will just make sure you're using the awesomeness of jQuery...
<script src="http://code.jquery.com/jquery-latest.js"></script>

//This will bind your field to the change event using jQuery
<script type="text/javascript">
  $("#field1").change( function() {
    $("#field1_val").text($(this).val());
  });
</script>

Hope that points you in the right direction.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜