sumathi N
sumathi N

Reputation: 1

How To use Query string in java script?

I have Created calculator project. I have only two pages. Now my question how to pass input field value to another page? trying too many ways its Not Working.

What to do to pass input fields values from one page to another page?

My input fields code Looks Like

<p class="pull-right">DPA Minimum Buyer Contribution<br /></p>
    <div class="row">
        <div class="col-md-3">
        </div>
        <div class="col-md-6" style="padding-right:1%">
            <input type="text" id="txtLocationContactName5" class="txt"/>
        </div>
        <div class="col-md-3" style="padding-left:0%">

Another page name default_results.php I have created input fields

<div class="col-md-5 padding-rht">
    Minimum Buyer Contribution
    </div>
    <div class="col-md-2 padding-Zero"> 
        <input type="text" id="txtCustomerName3"  class="txt"  />
    </div>

I have tired in jQuery script

<script>
 $(function () {
        $("#btnQueryString").bind("click", function () {
            var url = "default_results.php?id=" + encodeURIComponent($("#txtLocationContactName5").val()) + "&technology=" + encodeURIComponent($("#txtCustomerName3").val());
            window.location.href = url;
        });
    });
</script

but Not working so how to pass value one page to other page ?

Upvotes: 0

Views: 76

Answers (1)

mfisher91
mfisher91

Reputation: 807

You're making life hard for yourself! A simple form is needed to help you pass data to another page :). See here for info on html Forms - http://www.w3schools.com/html/html_forms.asp

Here is a simple example for you:

<form action="page_2_link" method="POST">
   <input type="text" name="field1" value="easy">
   <input type="submit" name="button1" value="Submit">
</form>

Then on the second page you can do this to retrieve the form data:

<?php
   $blah = $_POST['field1']; // this now has the posted fields value
?>

I have given the second page answer in PHP as you have used this as a tag for this question, so I hope you are using this or my answer won't work.

Upvotes: 1

Related Questions