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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nelluru
    New Member
    • Mar 2007
    • 31

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

    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:
    Code:
    //javascript function
    function changeSelectAction(form)
      {
         //form.action = 'det.php';
         document.forms['form-name'].action = 'det.php';
      }
    
    //html code
    <select name = "cli" onchange="return changeSelectAction(this.form);">
    <option value = "X">X </option>
    <option value = "Y">Y </option>
    <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
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    Originally posted by Nelluru
    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.


    Code:
        function changeSelectAction(form){
            document.forms['form-name'].submit();
        }

    Comment

    • Nelluru
      New Member
      • Mar 2007
      • 31

      #3
      Originally posted by pronerd
      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.


      Code:
          function changeSelectAction(form){
              document.forms['form-name'].submit();
          }

      thanks that worked well

      regards
      Nelluru

      Comment

      Working...