2uzhan.com
Advertisement
Now Place:2uzhan.com » pass the text box value from one form to another form textbox jquery

pass the text box value from one form to another form textbox jquery

Web Development @ October 19, 2015   Views:0

i need one form textbox value change, In that value pass into another form textbox in my website....

--------------Solutions-------------

I have tried below code .. its working fine and textbox value should be passing in same form ....but i need one textbox to be one form and another text box to be in another form value should be passed....
$(document).ready(function()
{ $("#query2").blur(function(e)
{
$("#search_head #query").val($(this).val()); }); });

<form id="search_head">

    <input id="query" />
    <input id="query2" placeholder="Blur me" value="Hi there" />
</form>

Use .change() .For text boxes, you probaby won't see any difference though.

JS

$('#query2').change(function(){$('#query').val($(this).val())});

HTML

<form>
    <input id="query">
</form>

<form>
    <input id="query2">
</form>

However, if these are on different pages i.e. you need to submit to the server, this won't work. But then you didn't say that.

@diafol thanks for your response ..yeah i need to code for not same page , these two textboxes are diffrent page and how to change textbox1 value should be affected in another form value of textbox2 ??? that only i needed ...

OK, assuming you are submitting the first form normally (submit button->server->operations->response [e.g. serve new page with 2nd form]).
This will have nothing to do with jQuery, unless you want to use webstorage - which I wouldn't suggest for this. It's pure PHP.

You can store the changed data "permanently" in a DB or file or you can store it temporarily in a COOKIE or a session variable. It depends on what the change is supposed to do. If it is part of a 'wizard' or multi-step type form, then you may want to use a session variable. If it is like a change of address, then this would be a permanent change, so use a DB. These are pretty loose rules, since there are many exceptions.

handlers/firstformhandler.php

<?php
session_start();
if($_POST && isset($_POST['query']))
{
    $_SESSION['query_val'] = $_POST['query'];
    $loc = '../secondform.php';
}else{
    $loc = '../firstform.php';
}
header("Location: $loc" );
exit;

secondform.php

<?php
session_start();
$qryVal = '';
if(isset($_SESSION['query_val']))
{
    $qryVal = $_SESSION['query_val'];
    unset($_SESSION['query_val']);
}
?>

<!-- later on -->
<form>
    <input id="query2" value="<?=$qryVal?>" />
</form>

Many variations of this type of thing.

I'm attempting to simplify my fundraising page, and would like to show exactly how much each donation would help us out. I've listed the options below, but I would like ...

I'm currently doing some encoding work to protect a site from XSS attacks. We've stuck a bunch of <script>debugger;</script> tags in the db. Dispite my best efforts, the strings I've ...

    //The php section of the code

           <?php

           function getJSONFromDB($sql){

           $conn = mysqli_connect("localhost", "root", "","rent");

           //echo $sql;

           $result = mysqli_query($conn, $sql)or die(mysqli_error());

           $arr=array();

           while($row = mysqli_fetch_assoc($result)) {

                   $arr[]=$row;

               }

               return json_encode($arr); ...
© 2018 2uzhan.com Contact