Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help to debug...

Status
Not open for further replies.

Berns

IS-IT--Management
Apr 25, 2002
41
US
Can anyone tell me why this script isn't working, I'm pretty sure that the problem is here (in the body):

<a href=&quot; + strSvr +&quot;><b>text text</b></a>

the entire script:


<script>
function getNvp(strKey) {
strVal = window.location.search.substr(1);
if(strVal.indexOf(strKey) >= 0)
{
strVal = strVal.substr(strVal.indexOf(strKey) + strKey.length);
// Check for & or +
if(strVal.indexOf(&quot;&&quot;) >= 0)
{
strVal = strVal.substr(0, strVal.indexOf(&quot;&&quot;));
}
else if(strVal.indexOf(&quot;+&quot;) >= 0)
{
strVal = strVal.substr(0, strVal.indexOf(&quot;+&quot;));
}
}
else
{
strVal = &quot;&quot;;
}

return strVal;
}

// Get the server name
strSvr = getNvp(&quot;source=&quot;);

strUrl = &quot;<a href= + strSvr+&quot;><font
color=#cc0000><b>pre-application approval</b></font></a>&quot;;
document.write (strUrl)
</script>


in the body (I'm pretty sure that this is where the problem is:

<a href=&quot; + strSvr +&quot;><b>text text</b></a>


All help is appreciated, thank in advance!
 
give this a shot...

strUrl = '<a href=&quot; + strSvr + '><font color=#cc0000><b>pre-application approval</b></font></a>';

note the single quotes as well as the embedded double quotes. Works kinda like paranthesis - you have to match pairs and placement. If you had opened a javascript console after you tried to open your page, you would have seen the error! There's always a better way...
 
this is prbably the sloppiest thing I've ever written in javascript but it will work
replace
<a href=&quot;with this
<script>{document.write(&quot;<a href=&quot;+&quot;
you were correct that the syntax for the link was very wrong. you can't jsut concatinate a variable into a string without being in the <script> tags
I dare to learn more
admin@onpntwebdesigns.com
 
BTW
take out the ; at the end of the links. These are placed there by TT
so the corrected should look like this
Code:
<script>{document.write(&quot;<a href=&quot;+&quot;[URL unfurl="true"]https://tester.test.com/testPubView01?source=&quot;+strSvr+&quot;>&quot;);}</script>[/URL]
I dare to learn more
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top