Creating dynamic hyperlink from form input

Discussion in 'ASP' started by danielson, Jun 29, 2009.

  1. danielson

    danielson New Member

    Joined:
    Jun 29, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hey guys,
    This is my first question on this forum, so I hope you'll be able to help. I want to place a form on a Sharepoint site. I want to be able to enter a number into that form and have it take me to the following hyperlink:
    ttp://server/page/Main.htm?ServerFilter="PRNumber=VARIABLE"
    ie:
    ttp://server/page/Main.htm?ServerFilter="PRNumber=8786"
    or
    ttp://server/page/Main.htm?ServerFilter="PRNumber=8121"
    Hopefully pretty simple.
     
  2. danielson

    danielson New Member

    Joined:
    Jun 29, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    all those links should say http but the form moderator wouldn't let me submit with too many live links.
     
  3. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
    Hi danielson,

    Welcome to the forum :)

    I think this is what you required :

    HTML:
    <head>
    <script language="JavaScript">
    	function onlyNumbers()
    	{
    		valid=true;
    		var Numbers = '0123456789';
    		var Field1 = document.form1.number.value;
    
    		if (Field1 == "")
    		{
    			alert ( "Please enter a number.." );
    			valid = false;
    		}
    		for (i=0; i < Field1.length; i++)
    		{
    			if (Numbers.indexOf(Field1.charAt(i),0) == -1)
    			{
    				alert ( "Numbers only !!" );
    				valid = false;
    				break;
    			}
    		}
    		if (valid)
    		{
    			document.location = "http://server/page/Main.htm?ServerFilter=\"PRNumber=" + Field1 + "\"";
    		}
    	}
    </script>
    </head>
    <body>
    <form name="form1">
    <br><br>
    <center><b>Number:&nbsp;  
    <input type="text" name="number">
    </b></center>
    <br><br><br>
    <center>
    <input type="button" name="Submit" value="Submit" onclick="onlyNumbers();"> &nbsp;&nbsp;&nbsp;&nbsp; 
    <input type="reset" name="Reset" value="Reset"></center>
    </body>
    
    This is an example page, which shows a textbox into which the user enters a number and is redirected to the required page on clicking submit.
     
    Last edited: Jun 30, 2009
  4. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth
    Hey, tried it out with my code, good one..... :)
     
  5. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
    Thanx :)
     
  6. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth
    Welcome :) How to insert this smilyes ?
     
  7. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
    When you are posting replies, click "Go Advanced". You will see a lot of smileys :)
     
  8. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth
    :crazy:

    Cool, nice one, again, Thanks for this :pleased:
     
  9. danielson

    danielson New Member

    Joined:
    Jun 29, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Cool, but there is one problem. It only works sometimes. For instance, I placed the HTML code on my desktop and saved the text as .htm-

    Open the file in IE and click to accept blocked content. Then I entered a number. Sometimes it works and goes to the document.location url.. but sometimes it just goes to:
    ile:///C:/Documents%20and%20Settings/bomgardd/Desktop/pr.htm?number=32155

    working:
    ttp://server/page/Main.htm?ServerFilter="PRNumber=98656"
     
  10. danielson

    danielson New Member

    Joined:
    Jun 29, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Well, I disabled the mcafee scriptproxy addon in IE. This script then worked like a charm.
    I will try to provide some input on the final fix if I decide to mess with this proxy.
     
  11. danielson

    danielson New Member

    Joined:
    Jun 29, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Not working again.. I reset all the settings to default in IE and still no go. I have no group policy added and IE is at default. WTF? Anyone have any ideas on how to get this script to work. still not grabbing the document.location.. just appending the pr number to the end of the current working directory.
     
  12. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
    Try window.location.href or simply location.href instead of document.location, and tell me the result.
     
  13. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth
    Tha'ts Cool :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice