I want to identify from what website a user has submitted a contact form.
The contact form is an include file (.shtml) and this file is being used on two different websites. Since it's only one file (include), will a javascript if...else
statement or switch
statement do this? If so, how would it be written?
I'm new to JavaScript and haven't had to write much so would appreciate help with the syntax.
I thought about adding two hidden fields on the one include contact form, with IDs of the two different sites:
html
<input type="hidden" data-id="new_student_signup" name="student_signup" value="" />
<input type="hidden" data-id="existing_student_signup" name="existing_student_signup" value="" />
js
if(data-id="new_student_signup"){
// this user came from the new student website
code if this condition is true
}
else if(data-id="existing_student_signup"){
// this user came from the existing student website
code if this condition is true
}
Or should I just create a new include file for the other website and add the hidden field to that file instead of using javascript on one include?
I'll admit, that seems easiest for a JavaScript novice like me, but I do like the idea of learning more JavaScript.