[LINK] RFI: Inserting Variables in HTML
Roger Clarke
Roger.Clarke at xamax.com.au
Wed Dec 20 16:24:57 AEDT 2006
I want to add to the APF site a feature that leverages off Google
News, to enable a search for the latest news in the privacy arena.
Test-page at:
http://www.privacy.org.au/Resources/News.html
Google's code is buried in all manner of clevernesses that I don't
want to get involved with.
My requirement is:
__________________________________________________________________________
Use a form to capture $VARIABLE='KEYED-DATA'
Generate and send:
http://news.google.com/news?hl=en&ned=us&q=$VARIABLE&btnG=Search+News"
^^^^^^^^
__________________________________________________________________________
I can do a form fine.
But (as a dead-parrot programmer - 1967-82), I have two problems:
(1) I don't know how to reference in HTML a variable whose value is
set in Javascript. In the fragments below, the relevant variables
are: $searchterm (what the requestor types in)
$searchrequest (the URL that's customised and sent to Google)
(2) I don't know which sequence to put the Javascript and the form in
(because their syntax is such that each references the other).
Maybe I need one form to capture the text, and another, with hidden
variables only, to send the string to Google?
The two fragments I'm playing with are:
<form action="$searchrequest" method="get">
<table border="0" cellpadding="10" cellspacing="0" width="90%">
<p></p>
<tr>
<input type="text" maxlength="800" name="searchterm" size="60" />
</tr>
</table>
</form>
<script type="text/javascript">
var
searchrequest="http://news.google.com/news?hl=en&ned=us&q=$searchterm&btnG=Search+News"
</script>
[I know this is a pretty dumb request; but The Link Institute is
both frighteningly competent and fairly tolerant of dumb questions.
Thanks!]
--
Roger Clarke http://www.anu.edu.au/people/Roger.Clarke/
Xamax Consultancy Pty Ltd 78 Sidaway St, Chapman ACT 2611 AUSTRALIA
Tel: +61 2 6288 1472, and 6288 6916
mailto:Roger.Clarke at xamax.com.au http://www.xamax.com.au/
Visiting Professor in Info Science & Eng Australian National University
Visiting Professor in the eCommerce Program University of Hong Kong
Visiting Professor in the Cyberspace Law & Policy Centre Uni of NSW
More information about the Link
mailing list