/    Sign up×
Community /Pin to ProfileBookmark

Problem retaining search parameters after query

Hi everyone-

This is my 1st post to this forum, and I would great appreciate it if anyone can help me with an issue I’m having.

Please visit my site – [URL=”http://allofcraigs.com”]http://allofcraigs.com[/URL]

If you do a search using all the available parameters, after submitting the query, not all the search parameters retain.

Any idea what I can do to fix this? Thanks!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@ZeroKilledApr 17.2009 — forms was never designed to retain input value after submit. however, the ability to make them appear is because language provide dynamic content. there are two solutions.

server side: read the request to determine which input user made. when value are available set it to field's value. i prefer this solution because it don't require the client to support/enable any technology (like JavaScript language).

client side: require the ability of a language to read the query string and set it dynamically to each field. however, this solution may not be reflected immediately depending on the used code. javascript savvy recommend to use DOM (because is popular and accepted by coder, the old document.write has been let back despite isn't deprecated) to manipulate the document and it have some side effect like waiting the document to be completely loaded, or at least the FORM tag. my opinion, document.write isn't good because if javascript is disabled/unsupported, then the form will not display correctly.

decide which solution you want.
Copy linkTweet thisAlerts:
@rcollamoreauthorApr 17.2009 — Thanks for the response.

It has to be a client side solution, as I'm using blogger.

What can I do? Thanks again!
Copy linkTweet thisAlerts:
@Eugene_MagdelApr 17.2009 — get values out of form by calling a function document.form. etc, and then through that function, you can call another one that would set the value back to the input field
Copy linkTweet thisAlerts:
@rcollamoreauthorApr 17.2009 — Hi Eugene-

Sorry if I sound ignorant, but can you give me an example? When it comes to javascript, I'm retarded. Most of what I have on there I found. I can implement the stuff, I just can't write it.

Thanks for your patience and help
Copy linkTweet thisAlerts:
@ZeroKilledApr 21.2009 — here is a sample:
<i>
</i>&lt;html&gt;
&lt;body&gt;

&lt;script type="text/javascript"&gt;
String.prototype.query = function(name, split, begin){
if(!split)var split = ['&amp;', '='];
if(split.constructor != Array || split.length != 2)throw new TypeError('Excepted type of argument not valid or argument lenght size not allowed.');
var query = this;
var queryObj = {};
if(begin)query = query.replace(begin, '');
query = query.split(split[0]);
while(query.length){
var pair = query.shift().split(split[1]);
if(pair[0] in queryObj){
if(queryObj[pair[0]].constructor != Array)queryObj[pair[0]] = new Array(queryObj[pair[0]]);
queryObj[pair[0]].push(decodeURIComponent(pair[1]));
}
else queryObj[pair[0]] = (pair[1])? decodeURIComponent(pair[1]): undefined;
}
if(name != null)return queryObj[name];
return queryObj;
}

onload = function(){
var _get = location.search.query(null, null, /^?/);
var form = document.getElementById('info');
for(var param in _get){
if(!_get.hasOwnProperty(param) || !param)continue; // prevent reading properties and method not defined in the object;
form[param].value = _get[param];
}
}
&lt;/script&gt;


&lt;form id="info"&gt;
&lt;p&gt;&lt;input type='text' name='username' /&gt; User name:&lt;/p&gt;
&lt;p&gt;&lt;input type='text' name='mail' /&gt; Mail:&lt;/p&gt;
&lt;p&gt;&lt;input type='text' name='phone' /&gt; Phone:&lt;/p&gt;
&lt;p&gt;&lt;textarea name='request'&gt;&lt;/textarea&gt; Detail your request:&lt;/p&gt;
&lt;p&gt;&lt;input type='submit' value='send' /&gt;&lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;


however, unless you are the owner of the search engine, javascript isn't your solution. according to what you explain, the site is going to be included in your blog which i assume both reside on different domain. if true, then javascript isn't your solution.
×

Success!

Help @rcollamore spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...