Carry value to URL script

Discussion in 'Programming' started by twins0203, Aug 21, 2006.

  1. #1
    I wasn't too sure where I should post this, so I put it here.

    What I'm wanting to do is list multiple offers that users can sign up for and have a text field beside each for them to enter in their username and it be put at the end of the URL. For instance, the site it would send them to would be www.website.com/offer1001&s1=______ The '_____' would be their username that they entered into the text field.

    I found a javascript that would do this, but I can only put one offer on each page with that script :(

    Anyone point me in the right direction as to how to go about doing this?
     
    twins0203, Aug 21, 2006 IP
  2. Darrin

    Darrin Peon

    Messages:
    123
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Mabye it might be easier to modify the script that you have working to add the additional parameters?

    How are you picking up the values on the site you are sending them too? Could you post the values in a form?
     
    Darrin, Aug 21, 2006 IP
  3. twins0203

    twins0203 Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Darrin,

    Here's the script that I found that seems to work when there's only 1 offer on the page. If I add any more, it sends them to the address in the last one on any of the offers that I have listed.

    <script type="text/javascript">
    function goto(it) {
    window.location.href="http://www.mb01.com/lnk.asp?o=72&c=3263&a=11301&s1=" + it.value + "";
    }
    </script>
    <form onsubmit="return false">
    <input name="go" type="text" size="20">
    <button value=" GO! " onclick="goto(this.form.go)">
    </form>Go</td>

    Any ideas?

    Thanks!
     
    twins0203, Aug 22, 2006 IP
  4. Darrin

    Darrin Peon

    Messages:
    123
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sure, try something like this, if I understand correctly. Here I added a couple more input boxes at appended the values to your URL. I changed the parameter that is passed to your goto() function to be the form object, and that way you can reference the different inupts from it in the function:

    <script type="text/javascript">
    function goto(it) {
    window.location.href="http://www.mb01.com/lnk.asp?o=72&c=3263&a=11301&s1= + it.go.value + "&of2=" + it.offer2.value + "&of3=" + it.offer3.value;
    }
    </script>
    <form onsubmit="return false">
    <input name="go" type="text" size="20">
    <input name="offer2" type="text" size="20">
    <input name="offer3" type="text" size="20">
    <button value=" GO! " onclick="goto(this.form)">
    </form>Go</td>

    Hope that helps.
     
    Darrin, Aug 22, 2006 IP
  5. twins0203

    twins0203 Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi Darrin,

    This is how I had it on my page before finding out that they didn't work. I guess there needs to be a 'Go' button next to each input box.

    agigforimages .com/images/twins0203/offers.jpg (Delete the space after images, I can't have live links yet...

    Any idea how I can do it like this?

    Thanks again!
     
    twins0203, Aug 23, 2006 IP
  6. Darrin

    Darrin Peon

    Messages:
    123
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I don't understand?

    This is how you want your URL to look?
    agigforimages .com/images/twins0203/offers.jpg

    You want this to be dynamically created in javascript? You can build the link however you want based on the values of the fields. I think you need to explain a little more. This URL looks nothing like the previous example with the parameters in the URL and the javascript to create it.
     
    Darrin, Aug 24, 2006 IP