By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,029 Members | 1,314 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,029 IT Pros & Developers. It's quick & easy.

how to reload page depending on the selection in the select tag in html

P: 31
hi all,
I am using HTML, Javascript and CSS to code my pages.

I want to reload the same page upon selecting an option to get data from mysql tables depending on the option.

this is my sample code:
Expand|Select|Wrap|Line Numbers
  1. //javascript function
  2. function changeSelectAction(form)
  3.   {
  4.      //form.action = 'det.php';
  5.      document.forms['form-name'].action = 'det.php';
  6.   }
  7.  
  8. //html code
  9. <select name = "cli" onchange="return changeSelectAction(this.form);">
  10. <option value = "X">X </option>
  11. <option value = "Y">Y </option>
  12. <option value = "Z">Z </option>
the problem is that it is going into the function but no action is taken place.
the form data should go in POST method.
Where am I going wrong here???
Need suggestions or comments to solve this problem.

regards
Nelluru
Apr 14 '08 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 392
the problem is that it is going into the function but no action is taken place.
Thats because you have not told it to do anything. Setting the action attribute does not submit the form, and there is no need to set it with JavaScript unless you are creating that value dynamically for some reason. Other wise what you want to set the action attribute with HTML and do is something like this.


Expand|Select|Wrap|Line Numbers
  1.     function changeSelectAction(form){
  2.         document.forms['form-name'].submit();
  3.     }
  4.  
Apr 14 '08 #2

P: 31
Thats because you have not told it to do anything. Setting the action attribute does not submit the form, and there is no need to set it with JavaScript unless you are creating that value dynamically for some reason. Other wise what you want to set the action attribute with HTML and do is something like this.


Expand|Select|Wrap|Line Numbers
  1.     function changeSelectAction(form){
  2.         document.forms['form-name'].submit();
  3.     }
  4.  

thanks that worked well

regards
Nelluru
Apr 15 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.