The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Placing variables into the middle of a URL
Rockster
post Feb 9 2010, 06:20 PM
Post #1





Group: Members
Posts: 5
Joined: 9-February 10
Member No.: 11,043



I'm working on a simple page for quickly accessing a Google Docs Spreadsheet visualization and performing queries on it. To do this I am trying to use two drop boxes to set the query conditions and then have a button to display the proper table below in a lower frame. However, the formatting of the url for these visualizations has the query set in the middle of the url, not at the end.

This is what I have so far:

CODE
<body>
<FORM METHOD="LINK" ACTION="http://spreadsheets.google.com/tq?tqx=out:html&tq=select )"+zonelist1+joblist+" and X

matches 'YES')&key=tY0W1AoVLIcIjx0JAP-mIsw">

<FORM NAME="job">
<SELECT NAME="zonelist1">
<OPTION VALUE="B,C,D,E,F,G,Y where (C ">Cities
<OPTION VALUE="B,M,N,O,Y where (M ">Outlands
<OPTION VALUE="B,S,T,Y where (S ">CoP Accessory
<OPTION VALUE="B,U,V,Y where (U ">AF2 -1
</SELECT>

<SELECT NAME="joblist">
<OPTION VALUE="WAR">WAR
<OPTION VALUE="MNK">MNK
<OPTION VALUE="WHM">WHM
<OPTION VALUE="BLM">BLM
</SELECT>


<INPUT TYPE="submit" VALUE="Query">
</FORM>

</body>


This does manage to pull out the information from the drop boxes, but the final url ends up something like this: http://spreadsheets.google.com/tq?zonelist...amp;joblist=BLM

instead of what it should be, like this:
http://spreadsheets.google.com/tq?tqx=out:html&tq=select B,M,N,O,Y where (C matches 'BLM' and X matches 'YES')&key=tY0W1AoVLIcIjx0JAP-mIsw

As you can see, it seems to cut off the URL early at the ?, then tries to put the query info in but doesn't finish off the URL.

I'm trying to set this up as simple as possible since I'm uncertain of what webhost I'll be able to put this page on. I figure I'll need to use javascript to get the information in the right fields and right order, but my attempts so far don't seem to be working.

Thank you in advance for your time and help.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 9 2010, 07:38 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



QUOTE
CODE
<FORM METHOD="LINK" ACTION="http://spreadsheets.google.com/tq?tqx=out:html&tq=select )"+zonelist1+joblist+" and X

matches 'YES')&key=tY0W1AoVLIcIjx0JAP-mIsw">


You must be joking. That URL is an anomaly . It can't possibly work. And there is no method "link".
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Rockster
post Feb 9 2010, 07:43 PM
Post #3





Group: Members
Posts: 5
Joined: 9-February 10
Member No.: 11,043



QUOTE(pandy @ Feb 9 2010, 06:38 PM) *

QUOTE
CODE
<FORM METHOD="LINK" ACTION="http://spreadsheets.google.com/tq?tqx=out:html&tq=select )"+zonelist1+joblist+" and X

matches 'YES')&key=tY0W1AoVLIcIjx0JAP-mIsw">


You must be joking. That URL is an anomaly . It can't possibly work. And there is no method "link".


I found the form method link mentioned in a book. If its incorrect, please let me know.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Feb 9 2010, 08:24 PM
Post #4


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



According to HTML 4.01, only get and post are allowed values for method.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Rockster
post Feb 9 2010, 08:37 PM
Post #5





Group: Members
Posts: 5
Joined: 9-February 10
Member No.: 11,043



Okay, thank you.

Any suggestions on how to get the proper info into the URL?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 9 2010, 10:11 PM
Post #6


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



What is the info?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Rockster
post Feb 10 2010, 03:18 PM
Post #7





Group: Members
Posts: 5
Joined: 9-February 10
Member No.: 11,043



I'm wanting to concatenate the results of the two drop-down boxes and submit that combined string text as a query.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 10 2010, 03:47 PM
Post #8


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



That happens automatically, it's the purpose of HTML forms. But first, you can't have two FORM tags and method="link" doesn't exist.

Let's start over. If you paste the below into a a HTML document, make some choices and submit the form you can see everything gets attached to the URL.

HTML
<form method="get" action="http://htmlhelp.com" enctype="text/plain">

<select name="animal">
<option>cat</option>
<option>dog</option>
<option>horse</option>
</select>

<select name="food">
<option>meatballs</option>
<option>porridge</option>
<option>steak</option>
</select>

<input type="hidden" name="car" value="BMW">
<input type="submit">

</form>


If you want additional options outside the user choices added, you can't add them to the URL in action. You have to use hidden input fields as I did with "car". The URL you submit to should of course be the one provided by Google and the name-value pairs you use must ones the google script understands.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Rockster
post Feb 10 2010, 04:17 PM
Post #9





Group: Members
Posts: 5
Joined: 9-February 10
Member No.: 11,043



The resulting URL from that code gives a format like this: http://htmlhelp.com/?animal=dog&food=p...dge&car=BMW

I need the resulting URL to be more like this: http://htmlhelp.com/?dog%20porridge%20BMW
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 10 2010, 05:09 PM
Post #10


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



You would have to do that programmatically. You can't get the form to produce a querystring with a single field concatenated from parts.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 06:42 PM