Home > front end >  There is a content parameters, want to let it automatically fill in different form?
There is a content parameters, want to let it automatically fill in different form?

Time:10-07

I now url links have a parameter, such as XXX. PHP? Lx=1, 2, the content of 3

Then I have x form page, now, and want to make the value of the above and fill out the form automatically when open the page,

,,,,,,,, and so on,,,

Then the lx values can automatically fill in separately to the front three forms,,,
Js, how to make? Have to be not done for a long time,,,,

CodePudding user response:

Js to get the url? At the back of the parameter selection
Var url=location. The search;//get the url "?" Following the string
Var theRequest=new Object ();
If (url. IndexOf ("?" )!=1) {
Var STR=url. Substr (1);
STRS=STR. Split (" & amp;" );
For (var I=0; I & lt; STRS. Length; I + +) {
TheRequest [STRS [I]. The split ("=") [0]]=unescape (STRS [I] the split ("=") [1]).
}
}
The console. The log (theRequest);

CodePudding user response:

The
leaf MAO response: 1/f, reference
js to get the url? At the back of the parameter selection
Var url=location. The search;//get the url "?" Following the string
Var theRequest=new Object ();
If (url. IndexOf ("?" )!=1) {
Var STR=url. Substr (1);
STRS=STR. Split (" & amp;" );
For (var I=0; I & lt; STRS. Length; I + +) {
TheRequest [STRS [I]. The split ("=") [0]]=unescape (STRS [I] the split ("=") [1]).
}
}
The console. The log (theRequest);


Hello, after the test can't, don't know where is there is a problem, can you give the complete some code, learning!
  • Related