SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Sweden
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change the VALUE in <form action="site.php?s=VALUE"....> with a <select>field?

    Hey! i need to change the value in <form action="server/script.php?s=VALUE"> with a <select>field

    I've tried this but it doenst work.

    HTML Code:
    <head>
    <script type="text/javascript">
        function onChange(katID) 
        { 
            document.forms[0].action = "server/script.php?s=" + katID; 
        }
        </script>
    </head
    and the form

    HTML Code:
    <form action="" method="post" enctype="multipart/form-data" id="form-demo">
    	
    <select name="katID" onChange="this.action = 'server/script.php?s=' + this.value">
    <option value="">Choose a category</option>
    <option value="1">Category #1</option>
    <option value="2">Category #2</option>
    <option value="3">Category #3</option>
    <option value="4">Category #4</option>
    <option value="5">Category #5</option>
    </select>

    i Cant use $_POST[katID] in the script im using so please dont comment that, why? i really dont know. It has something to do with the script im using

    If you need more information please ask for it.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to set the action of the form, because a select element doesn't have an action attribute.

    this.form.action should work.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •