Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
131
rated 0 times [  134] [ 3]  / answers: 1 / hits: 8205  / 10 Years ago, thu, july 24, 2014, 12:00:00

I have a jobs website with several different job description pages and with 1 application page with a form.



i.e.



/admin-clark -> /application
/sale-rep -> /application


I would like to pre-populate an input field in the form with the id #jobTitle.



I would like to do the following-




  • Get the previous URL

  • Store it in local storage

  • Sanatize url(remove dashes etc)

  • Use jQuery to fill in the field with id jobTitle



Or is a there a better way of doing this?



This is what I have so far



var pathname = window.location.path.replace(/^?$/, '').toUpperCase();
localStorage.setItem(pathname , pathname );
$('#jobTitle').val(pathname);

More From » jquery

 Answers
11

in many cases(Not in every case) will get you the URL of the last page if they got to the current page by clicking a link using document.referrer; See here



You can also take help from here


[#43635] Wednesday, July 23, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
neildrews

Total Points: 166
Total Questions: 103
Total Answers: 85

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
;