I'm not an expert in php. What I am trying to do is add a UPS tracking feature to my site. In order to check tracking info for UPS all that is needed is the tracking number at the end of their tracking url like the following.
http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1ZXXXXXXXXXXXXXXXX
How can I add a field on my site so that a user can enter the tracking number: 1ZXXXXXXXXXXXXXXXX and then click a button which will open a new window or tab with the entire url?
Any help is appreciated. Thanks in advance.
trackNums is a GET variable. You can use a GET form.
<form method="get" action="http://wwwapps.ups.com/WebTracking/track" target="_blank">
<input type="hidden" name="track" value="yes" />
<label for="trackNums">Tracking #</label><input type="text" id="trackNums" name="trackNums" value="" />
<input type="submit" value="Track" />
</form>
To keep the user on your website, but open this website in a new tab or window set the target attribute to _blank.
You can do this completely client-side:
<form action="http://wwwapps.ups.com/WebTracking/track" method="GET" target="_blank">
<input type="hidden" name="track" value="yes"/>
<input name="trackNums" />
<input type="submit" />
</form>
The target="_blank" has it open in a new window/tab.
You tagged this with PHP, but there is no need to use PHP. This can be done in JavaScript. The JavaScript function is:
window.location.href = "http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums="+trackingnumber;
Now, the key is to get the tracking number. That will be in a field on the database. Let's assume this is the field:
<input type='text' id='trnum'>
You get the value with:
var trackingnumber=document.getElementById('trnum').value;
That's all you need. Just call a function that changes the window.location.href using the value from the tracking number input field.
Related
I want to create a form about the job application page, but i want to do some validation about if the user already fill up all the element in the form, only the submit button can click, and the submit button will link to another html page to show "your application is successful received". How can i do, thank you so much. I so a part of my code
<label for="Minimum Salary (MYR)"><img src="Web Page Image (Koh Xin Hao)/Money.png"/> Minimum Salary (MYR)</label>
<input type="text" id="Minimum Salary (MYR)" name="Minimum Salary (MYR)" value="RM " maxlength="8" required="required">
<label for="Nationality"><img src="Web Page Image (Koh Xin Hao)/Card Issuing Country.png"> Nationality</label>
<input type="text" id="Nationality" name="Nationality" placeholder="Malaysia" required="required">
<div><p>The application process will take up to 2 days. If your application is approved by the company, we will inform you via email or telephone call. Thanks for you application ^-^</p></div>
<input type="submit" required="required" class="btn" onclick="location.href='Payment Successful.html'"/>
<button type="submit" class="btn" onclick="location.href='Payment Successful.html'">Submit</button>
Seen the form is not fill up anything but the submit button also can click. I already put required="required" inside my code but the validation is not working.
If i m not wrong so you want to ask that how to validate all fields and submit form to a new page.
If yes so
<input type="?" name="?" required />
add required attribute to require that feild
And give a action attribute to your form where u want to submit that form
Example <form action="your page" type="post">
Hope it helps you
Let me know if i misjudge your problem
You need to use Javascript to check if the fields have been filled in and if so disable the button.
You also need to change the required="required" to just required as shown here https://www.w3schools.com/tags/att_input_required.asp
You also need to wrap it all in a form tag and use the action field to supply the next page when it is submitted as per https://www.w3schools.com/tags/tag_form.asp
You may need to do more with validation in Javascript this is basicly only disabling the other button if the fields aren't blank. You can see more about JS validation here https://www.w3schools.com/js/js_validation.asp
function validateForm(){
var input1 = document.getElementById("input1").value;
var input2 = document.getElementById("input2").value;
if(input1==""){
console.log("input1 is blank!");
}else if(input2==""){
console.log("input2 is blank!");
}else{
console.log("inputs are not blank");
document.getElementById("button").disabled = true;
}
}
<form action="form_submitted_page" method="POST">
<label for="input1">input1</label>
<input type="text" id="input1" name="input1" required onchange="validateForm()">
<label for="input2">input2</label>
<input type="text" id="input2" name="input2" required onchange="validateForm()">
<input type="submit" value="Submit">
</form>
<button id="button" onclick="document.location.href='google.com'">Google (to be disabled)</button>
I've been working on having a form where a user can input a subreddits name in a input form and be taken to it, but not been working out well. I've tried using get and name="q" but it makes the address funky.
What I have so far:
<form method="post" action="http://www.reddit.com/r/" style="margin-left:5px;margin-right:5px;margin-bottom:0px;">
<input class="form-control" value="" placeholder="Subreddit Name">
</form>
If you're not getting what i'm trying to do: A user types text into an input, the text they typed would be sent to an address as reddit.com/r/(whatever the user typed)
Not knowing from your question whether or not you have access to server-side coding, and based on your answers in the comments, the following should work for you. Note that if a browser has JavaScript disabled, this will bring the user directly to http://www.redit.com/r/
If you have access to server-side scripting, you could add a catch on your server as well to avoid this.
<form method="post" onsubmit="document.location='http://www.reddit.com/r/'+document.getElementById('subredditname').value;return false;" action="http://www.reddit.com/r/" style="margin-left:5px;margin-right:5px;margin-bottom:0px;">
<input id="subredditname" class="form-control" value="" placeholder="Subreddit Name">
</form>
You can do this easily with PHP.
User types text into input field
<input type="text" name="user_text" />
After form submit, run PHP code
$page = $_POST['user_text'];
//send user to website
header('Location: http://reddit.com/r/' . $page);
My site has a page where I can parse specific logs by filling out form fields and pressing a submit button.Sometimes I have to parse 100 different logs(which are automatically downloaded by my site from another FTP location) so I'm trying to make it as automated as possible. I have created a file on my local PC named log.html with this content
<form action="MYSITEURL" method="POST" target="_blank" >
<input type="password" name="password" value="MYPASSWORD"/>
<input type="text" name="LogCommand" value="NAME-OF-THE-LOG-AND-LOCATION"/>
<input type="submit" value="Submit1stLog" />
</form>
When I open the log.html file on my local PC, it opens with Firefox and I can see 2 fields which are automatically filled with password and some other info that I need about the log file names and commands, and I have a Submit button. When I manually press Submit, the local file connects to my website and sends those values and submits it.Basically I fill out the form locally instead of going to my website. This way I can have 100 lines like the above one within one local HTML file and press 100 submit buttons manually, instead of going to my site 100 times.
My goal is to have some sort of JavaScript or something similar that will automatically click the Submit button for me as soon as I open the log.html local file.Is this possible? What if I have 100 Submit buttons?
I tried to put the following in log.html but it didn't work
<form action="MYSITEURL" method="POST" target="_blank" > <input type="password" name="password" value="MYPASSWORD"/> <input type="text" name="LogCommand" value="NAME-OF-THE-LOG-AND-LOCATION"/> <input type="submit" id="Submit1stLog" value="Submit1" /> </form>
<script>
function clickButton()
{
document.getElementById('Submit1stLog').click();
}
</script>
If you noticed,I added the id="Submit1stLog" part and then tried to get element ID. This didn't work and I'm terrible at this if you noticed so any help is appreciated !
Thank you.
Try to submit on page load :
window.onload = function(){
document.forms['FORM_NAME'].submit()
}
or you can also click button on page load , but submiting form might be better idea
Here is the Code :
<form name="SITEURL" action="MYSITEURL" method="post" target="_blank" >
<input type="password" name="password" value="MYPASSWORD"/>
<input type="text" name="LogCommand" value="NAME-OF-THE-LOG-AND-LOCATION"/>
<input type="submit" id="Submit1stLog" value="Submit1" />
</form>
<script>
window.onload = function(){
document.forms('SITEURL').submit();
}
</script>
free traffic exchange website
Check Out Post
I have two JSP pages A and B and also a Servlet.
The flow is like this:
User fill in some information in page A
Then the user fill in some other information in page B
After the user finishes B, he/she will click a button and submit all data (from both A and B) to the Servlet.
How should I design this?
My plan is
In A's next button, it is actually a <a> tag with link to the href of B. All information from A should be passed to B via that link. I don't know how to do this step.
In B's finish button, it is a form input submit button. I don't know whether I can or how I add A's data into this form.
Anyone can help me out?
Thanks
In your A.jsp create a link, for e.g.: Go to B
Pass your parameters from URL.
In B.jsp use expression language to get parameters values:
<form action="FinalServlet" method="post">
<input type="text" name="p" value="your value"/>
<input type="hidden" name="p1" value="${param.param1}"/>
<input type="hidden" name="p2" value="${param.param2}"/>
.......
<input type="submit" value="Finish"/>
</form>
Hope this helps.
EDIT:
If you want to use a form with input fields in A.jsp:
<form action="B.jsp" method="post">
<input type="text" name="param1" value="value1"/>
<input type="text" name="param2" value="value2"/>
.......
<input type="submit" value="Finish"/>
</form>
You will receive parameters in B.jsp using the same EL.
I want visitors to my website to be able to search for airport lounges offered by a company called Priority Pass. I have created the following form:
<form action="http://prioritypass.com/lounges/lounge-print.cfm" method="post">
<input type="text" id="print_airport_code" name="print_airport_code" value="MAN" />
<input type="submit" value="Submit" />
</form>
Which mirrors the form they have on their own mobile search site (here). But when I submit my form it doesnt seem like the parameters are being posted properly.
Any help would be great. Thanks.
The form on their website doesnt appear to contain any fields which I have missed?
You're pointing to the wrong URL; POSTing to /lounges/lounge-print.cfm is producing an HTTP redirect header, which is corrupting your output.
Additionally, the name of your input field is incorrect. Using someone else's form results often requires you to maintain all field names consistently as they appear on the remote site.
Change the form to:
<form action="http://www.prioritypass.com/mobile/lounges.cfm" method="post">
<input id="Airport_Code" name="Airport_Code" type="text" size="10" value="MAN" />
<input type="submit" value="Submit" />
</form>