Jump to content

pass text values via URL?


Charlatat
 Share

Recommended Posts

So would this syntax be correct?file://p:\webpages\OfficeLoc.html?address1=blah&state=blah&city=blah&zip=blah
I'm pretty sure you need three forward slashes if you are using the file protocol rather than http:file:///p:\webpages\OfficeLoc.html?address1=blah&state=blah&city=blah&zip=blahBut you have the parameters (query string) listed correctly.
Link to comment
Share on other sites

With the third "/", I didn't get any errors this time, thanks. However, its not filling in the fields like I expected it to. Here's the code for the html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE>MapQuest Directions from GoldMine</TITLE><script FOR=tdcLinks EVENT=ondatasetchanged>   // Once the recordset is available, set the web page URL to the last record in the data set   WEBLINK=tdcLinks.recordset.fields('Weblink');</SCRIPT><script FOR=btnLink EVENT=onclick>   window.open(WEBLINK);</SCRIPT><div style="display:none"><OBJECT classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83"	ID=tdcLinks HEIGHT=0 WIDTH=0>	<PARAM NAME="DataURL" VALUE="OfficeLoc.csv">	<PARAM NAME="UseHeader" VALUE="True"></OBJECT></div><H2> Contact's Address Information:</H2> <FORM action="http://www.mapquest.com" method="post">	<P>	<LABEL for="address">Address: </LABEL>			  <INPUT type="text" id="address"><BR>	<LABEL for="city">City: </LABEL>			  <INPUT type="text" id="city"><BR>	<LABEL for="state">State: </LABEL>			  <INPUT type="text" id="state"><BR>	<LABEL for="zip">Zip Code: </LABEL>			  <INPUT type="text" id="zip"><BR>	</P> </FORM><br><H2>Select an Office:</H2>Click this button to get directions to: <TAB><BUTTON ID="btnLink" DATASRC="#tdcLinks" DATAFLD="Office"></BUTTON><BR><BR><INPUT ID=cmdNavFirst TYPE=BUTTON VALUE="<<" 	onclick="tdcLinks.recordset.MoveFirst()"><INPUT ID=cmdNavPrev TYPE=BUTTON VALUE="<" STYLE="width:20px"	onclick="tdcLinks.recordset.MovePrevious(); if (tdcLinks.recordset.BOF)tdcLinks.recordset.MoveFirst();"><INPUT ID=cmdNavNext TYPE=BUTTON VALUE=">" STYLE="width:20px" 	onclick="tdcLinks.recordset.MoveNext(); if(tdcLinks.recordset.EOF)tdcLinks.recordset.MoveLast();"><INPUT ID=cmdNavLast TYPE=BUTTON VALUE=">>" 	onclick="tdcLinks.recordset.MoveLast()"></BODY></HTML>

Link to comment
Share on other sites

The fields will not auto populate you need to do that with some code. Save the code below in a file called request.js and put in the same folder as the html page.

//Request Object	var Request = 	{		QueryString: [],//return value of given variable	}	//load Request.QueryString	var q = window.location.href.split('?')[1];	var pairs = (q != null) ? q.split('&') : [];	for(var i=0;i<pairs.length;i++)	{		var pair = pairs[i].split('=');		Request.QueryString[pair[0]] = (pair == null) ? pair[1] : "";	}

then in the <head></head> of your page load the above file like this

<script type="text/javascript" src="request.js"

Then below the above line put this

<script type="text/javascript">  onload= function()  {	document.getElementById('address').value = Request.QueryString["address"];	document.getElementById('city').value = Request.QueryString["city"];	document.getElementById('state').value = Request.QueryString["state"];	document.getElementById('zip').value = Request.QueryString["zip"];  }</script>

This should work. If it doesn't post the whole code again so I can see if there where any glitches in implementing this. Good luck.

Link to comment
Share on other sites

still nada.buttons.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><script type="text/javascript" src="request.js"</HEAD><TITLE>MapQuest Directions from GoldMine</TITLE><script type="text/javascript">  onload= function()  {	document.getElementById('address').value = Request.QueryString["address"];	document.getElementById('city').value = Request.QueryString["city"];	document.getElementById('state').value = Request.QueryString["state"];	document.getElementById('zip').value = Request.QueryString["zip"];  }</script><script FOR=tdcLinks EVENT=ondatasetchanged>   // Once the recordset is available, set the web page URL to the last record in the data set   WEBLINK=tdcLinks.recordset.fields('Weblink');</SCRIPT><script FOR=btnLink EVENT=onclick>   window.open(WEBLINK);</SCRIPT><div style="display:none"><OBJECT classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83"	ID=tdcLinks HEIGHT=0 WIDTH=0>	<PARAM NAME="DataURL" VALUE="OfficeLoc.csv">	<PARAM NAME="UseHeader" VALUE="True"></OBJECT></div><H2> Contact's Address Information:</H2> <FORM action="http://www.mapquest.com" method="post">	<P>	<LABEL for="address">Address: </LABEL>			  <INPUT type="text" id="address"><BR>	<LABEL for="city">City: </LABEL>			  <INPUT type="text" id="city"><BR>	<LABEL for="state">State: </LABEL>			  <INPUT type="text" id="state"><BR>	<LABEL for="zip">Zip Code: </LABEL>			  <INPUT type="text" id="zip"><BR>	</P> </FORM><br><H2>Select an Office:</H2>Click this button to get directions to: <TAB><BUTTON ID="btnLink" DATASRC="#tdcLinks" DATAFLD="Office"></BUTTON><BR><BR><INPUT ID=cmdNavFirst TYPE=BUTTON VALUE="<<" 	onclick="tdcLinks.recordset.MoveFirst()"><INPUT ID=cmdNavPrev TYPE=BUTTON VALUE="<" STYLE="width:20px"	onclick="tdcLinks.recordset.MovePrevious(); if (tdcLinks.recordset.BOF)tdcLinks.recordset.MoveFirst();"><INPUT ID=cmdNavNext TYPE=BUTTON VALUE=">" STYLE="width:20px" 	onclick="tdcLinks.recordset.MoveNext(); if(tdcLinks.recordset.EOF)tdcLinks.recordset.MoveLast();"><INPUT ID=cmdNavLast TYPE=BUTTON VALUE=">>" 	onclick="tdcLinks.recordset.MoveLast()"></BODY></HTML>

request.js:

//Request Object	var Request = 	{		QueryString: [],//return value of given variable	}	//load Request.QueryString	var q = window.location.href.split('?')[1];	var pairs = (q != null) ? q.split('&') : [];	for(var i=0;i<pairs.length;i++)	{		var pair = pairs[i].split('=');		Request.QueryString[pair[0]] = (pair == null) ? pair[1] : "";	}

Link to comment
Share on other sites

change this

<HEAD><script type="text/javascript" src="request.js"</HEAD><TITLE>MapQuest Directions from GoldMine</TITLE><script type="text/javascript">  onload= function()  {	document.getElementById('address').value = Request.QueryString["address"];	document.getElementById('city').value = Request.QueryString["city"];	document.getElementById('state').value = Request.QueryString["state"];	document.getElementById('zip').value = Request.QueryString["zip"];  }</script><script FOR=tdcLinks EVENT=ondatasetchanged>   // Once the recordset is available, set the web page URL to the last record in the data set   WEBLINK=tdcLinks.recordset.fields('Weblink');</SCRIPT><script FOR=btnLink EVENT=onclick>   window.open(WEBLINK);</SCRIPT>

to this

<HEAD><script type="text/javascript" src="request.js"></script><TITLE>MapQuest Directions from GoldMine</TITLE><script type="text/javascript">  onload= function()  {	document.getElementById('address').value = Request.QueryString["address"];	document.getElementById('city').value = Request.QueryString["city"];	document.getElementById('state').value = Request.QueryString["state"];	document.getElementById('zip').value = Request.QueryString["zip"];  }</script><script FOR=tdcLinks EVENT=ondatasetchanged>   // Once the recordset is available, set the web page URL to the last record in the data set   WEBLINK=tdcLinks.recordset.fields('Weblink');</SCRIPT><script FOR=btnLink EVENT=onclick>   window.open(WEBLINK);</SCRIPT></HEAD>

Link to comment
Share on other sites

you know, when I put in this:http://avadaaudiology.awardspace.com/buttons.htmlThe fields are filled with "undefined", but when I put in this:http://avadaaudiology.awardspace.com/butto...ml?address=blahThe address field turns blank, but the others stay "undefined"
I think the problem is in this chunk of code:
	for(var i=0;i<pairs.length;i++)	{		var pair = pairs[i].split('=');		Request.QueryString[pair[0]] = (pair == null) ? pair[1] : "";	}

The last line assigns pair[1] to Request.QueryString[pair[0]] if pair == null and "" otherwise. Try changing it to this:

	for(var i=0;i<pairs.length;i++)	{		var pair = pairs[i].split('=');		Request.QueryString[pair[0]] = (pair == null) ? "" : pair[1];	}

Link to comment
Share on other sites

whoohoo! that works! even hosted locally, without a webserver it works... hehNOW, next 2 questions...now that the information is present in the fields, when a user clicks the button, it opens a new window.1. what's the command to direct the current page to the new URL instead of opening a new window?2. how do I pass the values from the fields to within the custom weblink (which is pulled from the csv file)?sorry about all the questions, I AM new and learning as we go

Link to comment
Share on other sites

window.location = "yoururl" + window.location.searchlocation.search grabs all the variable/value pairs fromt he current url and adds them at the end of the new url so it would equalyoururl?address1=blah&state=blah&city=blah&zip=blah

Link to comment
Share on other sites

umm, yeah....the < and > buttons scroll thru the choices from the csv file. It contains 2 fields, the office name, and a mapquest web link directing to the office's address. So, when a user clicks on the button that shows the office they want, it directs the page to the corresponding siteI need the info that you all helped me put into the fields to be automatically placed within the web link. Here's one of the links as an example:http://www.mapquest.com/directions/main.ad...z=55303&r=fDoes this make sense?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...