Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By Philip M

Thread: Link generator, combining fields. Newb question

  1. #1
    New to the CF scene
    Join Date
    Aug 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Link generator, combining fields. Newb question

    Hey guys, been having a tough time figuring out how to code something like this. Any help would be super appreciated!!


  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,302
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Something like this?

    Code:
    
    <textarea id = "ta1" rows = 10 cols =50></textarea>
    
    <script type = "text/javascript">
    
    var lowval = "TEST1"
    var highval = "TEST3"
    var baselink = "http://www.example.com/?y=1&z=2";
    var low = parseInt(lowval.replace(/[^0-9]/g, ""));
    var hi = parseInt(highval.replace(/[^0-9]/g, ""));
    var result = "";
    
    if (hi>=low) {
    for (var i = low; i<=hi; i++) {
    result += baselink + "&x4=TEST"+i+"&x5=" + "\n";
    }
    }
    else {alert("You must enter proper values")};
    
    document.getElementById("ta1").value = result;
    
    </script>
    “Education is the process of casting imitation pearls before real swine” - Irwin Edman
    Last edited by Philip M; 08-15-2014 at 11:26 AM.
    jinxus likes this.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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