1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Can someone help? Lookup coding

Discussion in 'HTML & Website Design' started by Luke1986, Oct 12, 2017 at 3:08 PM.

  1. #1
    Hi guys, I’m stumped.

    I’m wanting to add a postcode form field in my website and display certain links based on the postcode area inputted.
    SEMrush
    How would I go about this? I’ve been searching for days and can’t find anything.

    Any help would be much appreciated
     
    Luke1986, Oct 12, 2017 at 3:08 PM IP
    SEMrush
  2. SoftLink

    SoftLink Greenhorn

    Messages:
    15
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    8
    #2
    I'm not sure what you're asking for. Are you just trying to create a form and then retrieve the values or are you looking for resources or . . .
    Here's a basic html form and retrieval of field values in PHP.
    
    <?php
    
    $FName = $_POST["FirstName"];
    $LName = $_POST["LastName"];
    $Address = $_POST["Address"];
    $City = $_POST["City"];
    $State = $_POST["State"];
    $PostCode = $_POST["postcode"];
    
    $sRtn = $FName . " " . $LName . "<br/>";
    $sRtn .= $Address . "<br/>";
    $sRtn .= $City . ", " . $State . " " . $PostCode;
    
    echo $sRtn;
    
    ?>
    <!DOCTYPE html >
    <head>
    <meta content="charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Example Form</title>
    </head>
    
    <body>
    <form id="frmRec" action="" method="post">
    <table>
       <tr><td>Name: </td><td> <input name="FirstName" /> <input name="Last Name" /></td></tr>
      <tr><td>Address: </td><td><input style="width:30vw" name="Address" /></td></tr>
       <tr><td>City: </td><td><input style="width:30vw" name="City" /></td></tr>
       <tr><td>State: </td><td><input name="State" /> Postal Code: <input name="postcode" /></td></tr>
      <tr><td colspan=2 style="text-align:right;"><input type="submit" value="Submit" /></td></tr>
    </form>
    </body>
    </html>
    
    Code (markup):
     
    SoftLink, Oct 12, 2017 at 5:11 PM IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    23,572
    Likes Received:
    3,183
    Best Answers:
    87
    Trophy Points:
    615
    #3
    Hi Luke

    Your question can have short answers and long answers. On the face of it, if you're relatively inexperienced these are the steps I think you might want
    • User puts in address
    • Javascript eventListener sees that the postcode has changed
      • postcode captured
      • ajax call made to the server
      • server generates a new html snippet and sends it back to the browser
      • javascript takes the snippet and displays it on the page
    • User sees the new information
    Jquery will make some of the javascript work easier but it's still going to be a learning curve so work through tutorials and demos while you get the knack of it.
     
    sarahk, Oct 12, 2017 at 8:25 PM IP
  4. Luke1986

    Luke1986 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    What it’s for is as below.

    Imaging I have products
    A - £20
    B - £30
    C - £40

    I want a customer to enter their postcode and if they are within 10 miles of mine it will display product A, over 10 miles and under 20 it will show product B and over 20 it will show product C
     
    Luke1986, Oct 13, 2017 at 5:25 AM IP
  5. SoftLink

    SoftLink Greenhorn

    Messages:
    15
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    8
    #5
    You have to find a database of postal codes in the region that you want to sell.
    Here is a link to a site that sells those databases.

    You'll have to buy it and update it on a periodic basis because postal codes change.
    I would import that into MySql and use PHP to retrieve the values.
    You can use AJAX to do that but it's not necessary. Just add the database query and the links to the form I wrote for you above and you've got it.
     
    SoftLink, Oct 13, 2017 at 6:05 AM IP
  6. Luke1986

    Luke1986 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Thank you
     
    Luke1986, Oct 13, 2017 at 6:11 AM IP