A.php the top part of the page has some HTML code, there is a form, the form has a SELECT, input, button,
Form submitted to yourself: Form action= " "Method=" POST "
Now there is a problem, each time the page commits, the value of select is returned to the default value, and you want to keep the selected value intact. The code is designed as follows:
The onclick event of the button uses the JS code
I took the select value before the page was submitted and then gave it back to select, but I didn't succeed, so I thought of using the hidden field as the intermediate variable.
function Check () {
Document.form1.submit ();
var selvalue = document.getElementById ("sel");
var t = document.getElementById ("Bbsty");
for (i=0;i
if (t.options[i].value== selvalue) {
T.options[i].selected=true;
}
}
}
But why still can't succeed Ah! Please take a look, my idea is right, the code which block has a problem, how to achieve this function ah?
Reply to discussion (solution)
Thinking questions,
Document.form1.submit ();
After this thing is executed, it is not that you use the hidden input or the value that is saved with JS variable, the thing behind is white blind, because your page has jumped, equals you reload the current page.
So, if you want to make
Document.form1.submit ();
Behind the code execution, you must ensure that the current page is not reloaded, this should be your idea, not the way to save the value of the problem.
Tip: You can change the target of the form so that the form is submitted to an IFRAME with a width of 0, so that your page will not be reloaded. This will solve your problem.
In fact, there are many other ways to solve this problem, and we suggest that we should have time to think about it.
So I use $_post[' bbsty ' in a.php to get the value of SELECT, how to assign a value to select in a.php?
A lot of methods, this is a
I won't get the Select object in PHP, thanks for pointing!
Post to IFrame
or with Ajax.