Mod Rewrite with POST

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adamjblakey
    New Member
    • Jan 2008
    • 133

    Mod Rewrite with POST

    Hi,

    I have to list menus with date in both, what i want to do is when the user select data from them both and hits search i want it to come back with a url like this:

    www.website.com/post[list1]/post[list2]/

    How would i do this?

    Cheers,
    Adam
  • adamjblakey
    New Member
    • Jan 2008
    • 133

    #2
    Right i have worked out it would need a javascript solution but don't know exactly how this is done please see below:

    I assume it would be something like this:

    Code:
    <select name="service" id="service" onchange="changethis(name)>
    <option value="Test" selected="Test">Test</option>
    
    <select name="service2" id="service2" onchange="changethis(name)>
    <option value="Test" selected="Test">Test</option>
    
    <a href="http://www.website.com/updatevaluehere/updatesecondvaluehere/"><img src="image.jpg"></a>
    Cheers,
    Adam

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      But for a JavaScript solution this is the wrong forum. I will move this threwad to the DHTML/JavaScript/Ajax forum.

      MODERATOR

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by adamjblakey
        Right i have worked out it would need a javascript solution but don't know exactly how this is done
        No need for the onchange - just call a function onclick (of the link) which adds these to the href:
        [CODE=javascript]location.href = "http://www.website.com/" + document.getEle mentById("servi ce1").value + "/" + document.getEle mentById("servi ce2").value + "/";
        [/CODE]

        Comment

        • adamjblakey
          New Member
          • Jan 2008
          • 133

          #5
          Originally posted by acoder
          No need for the onchange - just call a function onclick (of the link) which adds these to the href:
          [CODE=javascript]location.href = "http://www.website.com/" + document.getEle mentById("servi ce1").value + "/" + document.getEle mentById("servi ce2").value + "/";
          [/CODE]
          Thank you very much for your reply.

          Is this right as i tried it here and it does not seem to work.

          Code:
          <input type="submit" name="Submit" value="Find" onclick="location.href="http://www.web.co.uk/" + document.getElementById("service").value + "/" + document.getElementById("location").value + "/";"/>

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You forgot to escape the quotes within quotes. Either use a single quote for the onclick encapsulating quotes or escape the double quotes using the backslash character.

            Comment

            • adamjblakey
              New Member
              • Jan 2008
              • 133

              #7
              Thanks this works fine now,

              What i need to do, and i don't know if this is possible but i need when a selection is made i need that selection if contains spaces for the spaces to be removed and replaced with - also i need the address to be changed to all lowercase.

              Can this be done, if so how?

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Originally posted by adamjblakey
                Thanks this works fine now,

                What i need to do, and i don't know if this is possible but i need when a selection is made i need that selection if contains spaces for the spaces to be removed and replaced with - also i need the address to be changed to all lowercase.

                Can this be done, if so how?
                The easy solution is to modify the value manually (if possible). That way there's no need to make any modifications afterwards, i.e. make sure that all spaces have been removed and the letters are lowercase.

                You can also use the replace method to remove spaces, e.g. val.replace(/\s+/g,"-") and the toLowerCase() method to convert a string into lowercase.

                Comment

                • adamjblakey
                  New Member
                  • Jan 2008
                  • 133

                  #9
                  Originally posted by acoder
                  The easy solution is to modify the value manually (if possible). That way there's no need to make any modifications afterwards, i.e. make sure that all spaces have been removed and the letters are lowercase.

                  You can also use the replace method to remove spaces, e.g. val.replace(/\s+/g,"-") and the toLowerCase() method to convert a string into lowercase.
                  thank you, i can not do this manually so would have to be the second option.

                  how would i go about implementing this into:

                  Code:
                  <input type="submit" name="Submit" value="Find" onClick="location.href='http://www.web.co.uk/' + document.getElementById('service').value + '/' + document.getElementById('location').value + '/';" />

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    [CODE=javascript]document.getEle mentById('servi ce').value.repl ace(/\s+/g,"-").toLowerCase( ) [/CODE]

                    Comment

                    Working...