开发者

how to Post values from one form to another form?

parent.html

<HTML>
<form name="form" method="post" action="child2.html">
<input type="text" value="" name="text2" id="pdetails2">
<input type=submit name="submit" value="submit"></form>
</html>

child2.html

<HTML>
<form name="form1">
<input type="text" value="" name="text3" id="pdetail开发者_高级运维s3">
</form><html>

here if i give any value in parent form text box once i click on submit button i need that text box valu in child2 form textbox what can i do?


For your specific solution: you can try it using javascript.

1.) Change the parent.html 's form's method to get instead of post i.e

<form name="form" method="get" action="child2.html">

2.) In child2.html add the following javascript function:

<script type="text/javascript">
    function $_GET(q,s) { 
        s = s ? s : window.location.search; 
        var re = new RegExp('&'+q+'(?:=([^&]*))?(?=&|$)','i'); 
        return (s=s.replace(/^?/,'&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined; 
    } 
</script>

3.) use $_GET('var1'); to get the value: e.g in ur textbox:

<input type="text" value="" name="text3" id="pdetails3">
<script>document.getElementById('pdetails3').value = $_GET('pdetails2');</script>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜