PDA

View Full Version : Form problem capturing referring URL content



jianxin9
09-26-2007, 06:19 PM
I have put together a form to pull information from a referring URL and put it into text boxes. When it pulls the info, it also pulls in all the "+" signs, etc. that separate each word in the URL. Is there anyway to alter it so that it will pull the words but not the extra symbols between words?

Thanks!



<html>
<head><title>Ill Form-Article Linker</title>
<script language="JavaScript">
function loadRefURL (){
document.forms[0].theAddr.value = document.referrer;
}</script>

<script language="JavaScript">
// JavaScript Document

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: wsabstract.com | http://www.wsabstract.com */
function checkrequired(which) {
var pass=true;
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("The "+shortFieldName+" field is a required field.");
return false;
} else {
return true;
}
}
</script>
<meta name="keywords" content="">
<meta name="Generator" content="HTMLpad">

<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-weight: bold;
}
-->
</style>



<script type="text/javascript">
function getQueryValue(name) {
var match = (new RegExp('[?&;]' + name + '=([^&;#]*)')).exec(document.referrer);

return match ? unescape(match[1]) : null;
}

function populateFields() {
var controls = document.forms.form1.elements,
fieldMap = {ArticleTitle: 'atitle', JournalTitle: 'title', ISSN: 'issn', DatePub: 'date',
StartPage: 'spage', Volume: 'volume', Issue: 'issue',
AuthorLastName: 'aulast', AuthorFirstName: 'aufirst', ArticleAuthor: 'author', Authors: 'authors'};

for (var i = 0, n = controls.length; i < n; ++i) {
var value = getQueryValue(fieldMap[controls[i].name]);
if (value) controls[i].value = value;
}
}
</script>

</head>


<body onLoad="populateFields(); loadRefURL()">

<form method=post action=http://ezproxy.twu.edu:2065/cgi-bin/aspmail.asp id=form1 name=form1 onSubmit="return checkrequired(this)">

<input type=hidden name=sendername value="Automailer">
<input type=hidden name=subject value="Request for interlibrary loan (generated by Article Linker results page)">
<input type=hidden name=recipientname value="ILL">
<input type=hidden name=recipientmail value="ill@mail.twu.edu">
<input type=hidden name=redirect value=http://ezproxy.twu.edu:2065/library/>
<input type=hidden name=userinfo value="on">


<span class="style1">Interlibrary Loan request form--TWU Libraries</span>

<br />
<br />


<b>Patron Last Name, First Name: (required field)</b>
<input type="text" name="required Name" size="50" /><br><br>
<b>Student ID: (required field)</b>
<input type="text" name="required ID#SSN" size="50" /><br><br>
<b>Patron Address: (required field)</b> <br />

<textarea name="required Address:" rows="3" cols="20" wrap="virtual"></textarea><br><br>


<b>Patron Email Address (required field): </b>
<input type="text" name="required Email Address" size="50"/><br><br>

<b>Phone: </b>
<input type="text" name="Phone" size="50"/><br><br>

<b>Pickup Location: </b>
<select id="Department" name="Campus">
<option selected>Denton</option>
<option>Parkland</option>

<option>Presbyterian</option>
<option>Houston</option>
<option>Distance Education</option>
</select>
<br />
<br />
<b>Campus Status: </b>
<select id="Status" name="CampusStatus">
<option selected>Undergraduate</option>

<option>Graduate</option>
<option>Distance Education</option>
<option>Faculty</option>
<option>Staff</option>
<option>Other</option>
</select><br /><br />
<b>Other Comments (optional): </b> <br />

<textarea name="Comments:" rows="3" cols="40" wrap="virtual"></textarea><br><br>


<strong>Please scroll down and submit the form. Do not edit any information below this point.</strong>

<br /><br />
<strong>

<label>Journal Title:</label> <input name="JournalTitle" type="text" /><br /><br />
<label>ISSN:</label> <input name="ISSN" type="text" /><br /><br />
<label>Volume: </label><input name="Volume" type="text" /><br /><br />

<label>Issue: </label><input name="Issue" type="text" /><br /><br />
<label>Date: </label><input name="DatePub" type="text" /> <br /><br />

<label>Article Title: </label><input name="ArticleTitle" type="text" /><br /><br />
<label>Author: </label><input name="ArticleAuthor" type="text" /><br /><br />
<label>Author Last Name: </label><input name="AuthorLastName" type="text" /><br /><br />

<label>Author First Name: </label><input name="AuthorFirstName" type="text" /><br /><br />

<label>Authors: <input name="Authors" type="text" size="50" / ></label><br /><br />
<label>Start Page: <input name="StartPage" type="text" size="50" /></label></strong><br /><br />





<strong>Date Requested: </strong><input type="text" name="Requested" size=11>
<br /><br />
<strong>Page URL: </strong><input type=text name="theAddr" size=50 /><br /><br />
<input type="submit" value="submit">


</form> <script>

/*Current date in form credit:
JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/

var mydate=new Date()
var theyear=mydate.getYear()
if (theyear < 1000)
theyear+=1900
var theday=mydate.getDay()
var themonth=mydate.getMonth()+1
if (themonth<10)
themonth="0"+themonth
var theday=mydate.getDate()
if (theday<10)
theday="0"+theday

//////EDIT below three variable to customize the format of the date/////

var displayfirst=themonth
var displaysecond=theday
var displaythird=theyear

////////////////////////////////////

document.form1.Requested.value=displayfirst+"/"+displaysecond+"/"+displaythird
</script>
</body>
</html>


<br><br>
























</body>
</html>



Reply With Quote