How to prefill a form

E

Evertjan.

jonathan wrote on 06 jun 2004 in comp.lang.javascript:
I want when visitors go to

http://www.1cellnetindonesia.com/ct_09DaftarSementara.html#Reg-Temp-Top
?memberlain=hardjoko&nama1=test

I want the field memberlain already filled with a name "hardjoko",
that sort of thing. Is there a way to do it?

Preferably you would do this with serverside code, like ASP(JS/VBS):

<form>
<input name="memberlain" value="<%=Request.querystring("memberlain")%>">
....

=====================================

clientside code is possible:

<script>
function getMemberlain(){
document.getElementById("").value =
document.location.search.replace(/^.*=/,"")
alert(m)
}
</script>
<body onload="getMemberlain()">
<form>
<input name="memberlain" id="memberlain" value="">
......

Not tested
 
R

Richard Cornford

Evertjan. wrote:
<snip>

It may, however, prove valuable for the OP to become familiar with RFC
2396 and the URI syntax it describes, as anything following the fragment
identifier separator - # - is likely to be treated as a fragment
identifier and _not_ as a query string. Making parameters appended to a
fragment identifier as if it was a query unavailable to -
location.search - and probably ASP - Request.querystring -.

Richard.
 
E

Evertjan.

Richard Cornford wrote on 06 jun 2004 in comp.lang.javascript:
Evertjan. wrote:

<snip>

It may, however, prove valuable for the OP to become familiar with RFC
2396 and the URI syntax it describes, as anything following the
fragment identifier separator - # - is likely to be treated as a
fragment identifier and _not_ as a query string. Making parameters
appended to a fragment identifier as if it was a query unavailable to
- location.search - and probably ASP - Request.querystring -.

I do not understand much of what you are saying, but then I am not the
OP.

What fragments do you want to be identified?

Could you explain in beginners language and in simpler English or
perhaps with a translation into Indonesian?

PS:
Just tested the clientside location.search solution.
It had no problems with the
#blah?a=n
string under IE6
 
R

Richard Cornford

Evertjan. said:
I do not understand much of what you are saying, but then I am not the
OP.

What fragments do you want to be identified?

Could you explain in beginners language and in simpler English ...
<snip>

Err, I don't know if I can explain it satisfactorily, but the URI
grammar rules are:-

<quote cite="RFC 2396 Section 4">
URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
</quote>

<quote cite="RFC 2396 Section 3">
absoluteURI = scheme ":" ( hier_part | opaque_part )
....
hier_part = ( net_path | abs_path ) [ "?" query ]
net_path = "//" authority [ abs_path ]
abs_path = "/" path_segments
</quote>

<quote cite="RFC 2396 Section 5">
relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
</quote>

- and given that grammar, a fragment identifier is an optionl part of a
URI-reference and will appear at the end of such a reference, while the
query string is an optional part of either an absoluteURI or a
relativeURI. As an absoluteURI or a relativeURI must appear in a
URI-reference before a fragment identifier (if they appear at all) then
a query string must precede a fragment identifier if the result is going
to conform to the grammar.
PS:
Just tested the clientside location.search solution.
It had no problems with the
#blah?a=n
string under IE6

Maybe, but relying on the behaviour of the very (perhaps overly)
tolerant IE to be reproduced in all other browsers would not be a my
approach to creating a reliable cross-browser end result.

Richard.
 
E

Evertjan.

Richard Cornford wrote on 06 jun 2004 in comp.lang.javascript:
Maybe, but relying on the behaviour of the very (perhaps overly)
tolerant IE to be reproduced in all other browsers would not be a my
approach to creating a reliable cross-browser end result.

At least I have never had any problems with ASP's

Request.querystring()

==============

The clientside solution with a location.search.replace() sequence
scould be improved upon,
but even better should be avoided if serverside coding is possible.
 
R

Richard Cornford

Evertjan. said:
At least I have never had any problems with ASP's

Request.querystring()

==============

The clientside solution with a location.search.replace() sequence
scould be improved upon,
but even better should be avoided if serverside coding is possible.

Interesting that you don't see constructing URIs to conform with the
specified grammar as the obvious way of avoiding any issue.

Richard.
 
E

Evertjan.

Richard Cornford wrote on 07 jun 2004 in comp.lang.javascript:
Interesting that you don't see constructing URIs to conform with the
specified grammar as the obvious way of avoiding any issue.

I am pleased that you find me interesting, Richard.

However, You are missing the point of this NG.

They are, among other uses,
for helping people that ask questions about relevant subjects.

I think it would be better if you take up the issue yourself,
as you seem to be very knowledgable about it.

So please advice the OP with your ideas.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top