Click here to Skip to main content
15,911,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want my customers to be able to track the arrival of the purchase by

1. go to my site
2. enter tracking number into a field
3. hit search
4. user taken to courier site and displayed tracking info

Courier site is https://app.starshipit.com/track.aspx?code=6823256031 (where 6823256031 is the tracking number).

What HTML do I have to add to capture the tracking number and then pass this through the 'search/track' button to the URL above.

Clearly i am a novice, and i appreciate the expertise and help of anyone who can offer their help.

Thank you

Is that what you were after?

What I have tried:

I can create a field, but dont know how to code for the field contents to populate into the URL
Posted
Updated 29-Jun-18 10:17am

There's no need to resort to Javascript if you set the form up correctly:
HTML
<form method="get" action="https://app.starshipit.com/track.aspx">
    <label for="code">Tracking code:</label>
    <input type="text" name="code" id="code" />
    <input type="submit" value="Track" />
</form>
 
Share this answer
 
That URL you provided us with, is that a dummy URL or something because it does not provide any useful information, nor does it accept any interaction.

Lastly, that can be done in a single field form, where you redirect the user to the site they are going to visit, I am writing the following code without testing, some minor elements would be needed to change,

HTML
<form>
   <label for="trackingCode">Tracking Code</label>
   <input type="text" name="trackingCode" id="trackingCode" />
   <input type="submit" value="Track" onclick="track();" />
</form>

Then you can add the following JavaScript, that will do the job,
JavaScript
function track() {
   var trackingCodeElement = document.getElementById("trackingCode");
   window.location.href = "https://app.starshipit.com/track.aspx?code=" + trackingCodeElement.value;
}

This code is prone to errors, like the value can be empty or so but you can check that, and in doing so you will learn some web development as well. :-)
 
Share this answer
 
Comments
Richard Deeming 4-Jun-18 9:13am    
No need for the Javascript - just set the form's action and method, and name the fields accordingly. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900