jettlarue2003
03-04-2005, 11:03 PM
Here is a short tutorial on dynamic-links which use javascript to create the page. Ok to start open up notepad and type
<html>
<head>
<title>My first dynamic link</title>
</head>
<body>
<script>
var name=prompt("Enter name:","");
var age=prompt("Enter age:","");
if (name == "" || age == ""){
document.write("Please reload and fill everything in.");
} else {
document.write('<a href="javascript:dp=\'Your name:'+name+'<br>Your age:'+age+'\';">Click here for dynamic page</a>');
}
</script>
<noscript><a href="getfirefox.com">Get a decent browser</a></noscript>
</body>
</html>
Ok save it and test it out. I am writing this kinda fast so if it doesnt work pm me or reply to this topic. Ok we will go over what it does now.
1. First it gives you the prompt name then age. It checks whether they are both filled in and if they arent it says to reload. Otherwise it writes down the link. Next we will go over the link.
2. Here is the infrastructure of the link.
1. the start of most links "<a href="
2. the starting of the string for the browser to connect to " " "
3. the tag that defines a javascript page and its name is dp. "javascript:dp"
4. what the javascript equals " = "
5. Start of the string for the javascript to do " ' "
6. Now it displays the text Your name: "Your name:"
7. It now appends the variable from the script name to it. EG:your name you entered. " '+name+' "
8. It makes a line break and displays the text Your Age: "<br>Your age:"
9. It now appends the variable from the script age to it. EG:your age you entered. " '+age+' "
10. Leaves a blank space " "
11. Starts to end the javascript string by closing the space for text and a semi-colon to end the page. "\';"
12. Ends the html string for the link and displays text for the link." ">Click here for dynamic page"
13. and now closes the link. " </a>
Make sure in the code you take out the space between java and script.
Hope you liked it post some feedback so I know if i should make an in-depth version (making it actually useful)
All the best...
EDIT:sorry for the crappy first script. il will work fine now(just forgot a few things).
-Jett
<html>
<head>
<title>My first dynamic link</title>
</head>
<body>
<script>
var name=prompt("Enter name:","");
var age=prompt("Enter age:","");
if (name == "" || age == ""){
document.write("Please reload and fill everything in.");
} else {
document.write('<a href="javascript:dp=\'Your name:'+name+'<br>Your age:'+age+'\';">Click here for dynamic page</a>');
}
</script>
<noscript><a href="getfirefox.com">Get a decent browser</a></noscript>
</body>
</html>
Ok save it and test it out. I am writing this kinda fast so if it doesnt work pm me or reply to this topic. Ok we will go over what it does now.
1. First it gives you the prompt name then age. It checks whether they are both filled in and if they arent it says to reload. Otherwise it writes down the link. Next we will go over the link.
2. Here is the infrastructure of the link.
1. the start of most links "<a href="
2. the starting of the string for the browser to connect to " " "
3. the tag that defines a javascript page and its name is dp. "javascript:dp"
4. what the javascript equals " = "
5. Start of the string for the javascript to do " ' "
6. Now it displays the text Your name: "Your name:"
7. It now appends the variable from the script name to it. EG:your name you entered. " '+name+' "
8. It makes a line break and displays the text Your Age: "<br>Your age:"
9. It now appends the variable from the script age to it. EG:your age you entered. " '+age+' "
10. Leaves a blank space " "
11. Starts to end the javascript string by closing the space for text and a semi-colon to end the page. "\';"
12. Ends the html string for the link and displays text for the link." ">Click here for dynamic page"
13. and now closes the link. " </a>
Make sure in the code you take out the space between java and script.
Hope you liked it post some feedback so I know if i should make an in-depth version (making it actually useful)
All the best...
EDIT:sorry for the crappy first script. il will work fine now(just forgot a few things).
-Jett