Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Show variable as a link in form output?

  1. #1
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Show variable as a link in form output?

    I admit I an a newb when it comes to alot of things.

    I have a countdown timer script that I am using for an Alumni website that allows me to show a countdown timer. The output variable of the timer shows based on 3 options, Shows a countdown timer if the time is in the future. It shows a message if the timer is set for the day of the event, and another message if the timer has past the date.

    Is there a way so that the output message is a link to a page.

    Example: As the script is showing below the timer is set so the event has past. So in the form box it shows "Class of 1965 - There is no reunion information available". Is there a way I can embed the above text with a link that would take you to another page? And is there a way to have the countdown timer have an embeded link as well. What I am trying to do is set it so that no matter what is showing in the form output field has an embedded link to a page for more information.

    <form name="count">
    <input type="text" size="67" name="count2" style="border:3px double #000000; font-family: Bell MT; font-size: 14pt; color: #000000; font-style:oblique; text-align:center">
    </form>

    <font color="#FFFF00"><span style="font-size: 1pt">

    <script>
    //Class of 1965
    //change the text below to reflect your own,
    var before="the class of 1965 reunion!"
    var current="Today is the day of the Class of 1965 Reunion!"
    var none="Class of 1965 - There is no reunion information available."
    var past="Class of 1965 - There is no reunion information available."
    var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

    function countdown(yr,m,d){
    theyear=yr;themonth=m;theday=d
    var today=new Date()
    var todayy=today.getYear()
    if (todayy < 1000)
    todayy+=1900
    var todaym=today.getMonth()
    var todayd=today.getDate()
    var todayh=today.getHours()
    var todaymin=today.getMinutes()
    var todaysec=today.getSeconds()
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
    futurestring=montharray[m-1]+" "+d+", "+yr
    dd=Date.parse(futurestring)-Date.parse(todaystring)
    dday=Math.floor(dd/(60*60*1000*24)*1)
    dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
    dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
    dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
    if(dday==0&&dhour==0&&dmin==0&&dsec==1){
    document.forms.count.count2.value=current
    return
    }
    if(yr==0&&m==0&&d==0){
    document.forms.count.count2.value=none
    return
    }
    if(dday<0){
    document.forms.count.count2.value=past
    return
    }

    else
    document.forms.count.count2.value="Only "+dday+ " days until "+before+ " "+m+ "/"+d+ "/"+yr
    setTimeout("countdown(theyear,themonth,theday)",1000)
    }
    //enter the count down date using the format year/month/day
    countdown(2012,6,10)
    </script>
    </span></font>
    Last edited by pgheagle; 07-31-2012 at 03:25 AM. Reason: Turn off smileys

  2. #2
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Can't you just put <a> tags around the different outputs?
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  3. #3
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Please use the forum's bbcode tags to make it more readable:

    for php code............[php] <?php /* code goes here */ ?> [/php]
    for html...............[html] <!-- markup goes here -->.....[/html]
    for js/css/other.......[code] code goes here................[/code]

  4. #4
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have tried what I thought with the <a>.

    var past=<a href = "reunion-1965.php" <b>Class of 1965 - There is no reunion information available.</b></a>

    But when I do that, the form output field shows nothing in it.

  5. #5
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Is it because you didn't actually end the start of the a tag? Try this:
    Code:
    var past=<a href="reunion-1965.php"> <b>Class of 1965 - There is no reunion information available.</b></a>
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  6. #6
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thanks, but that didn't help.

    Once you mentioned it, I realized that may be the problem. I even found one other open tag. (Stupid mistakes LOL!) But that didn't correct what I am trying to do.

    Here is the full script as I am trying to use it. You will notice there are two var=past lines (One commented out. I highlighted both lines.)
    If I use the one without the link it shows up and looks right.
    If I use the one WITH the link I get nothing in the form field at all.. :confused:


    <form name="count">
    <input type="text" size="67" name="count2" style="border:3px double #000000; font-family: Bell MT; font-size: 14pt; color: #000000; font-style:oblique; text-align:center">
    </input>
    </form>

    <font color="#FFFF00"><span style="font-size: 1pt">

    <script>
    //Class of 1965
    //change the text below to reflect your own,
    var before="the class of 1965 reunion!"
    var current="Today is the day of the Class of 1965 Reunion!"
    var none="Class of 1965 - There is no reunion information available."
    var past="Class of 1965 - There is no reunion information available."
    // var past=<a href = "reunion-1965.php"> <b>Class of 1965 - There is no reunion information available.</b></a>

    var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

    function countdown(yr,m,d){
    theyear=yr;themonth=m;theday=d
    var today=new Date()
    var todayy=today.getYear()
    if (todayy < 1000)
    todayy+=1900
    var todaym=today.getMonth()
    var todayd=today.getDate()
    var todayh=today.getHours()
    var todaymin=today.getMinutes()
    var todaysec=today.getSeconds()
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
    futurestring=montharray[m-1]+" "+d+", "+yr
    dd=Date.parse(futurestring)-Date.parse(todaystring)
    dday=Math.floor(dd/(60*60*1000*24)*1)
    dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
    dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
    dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
    if(dday==0&&dhour==0&&dmin==0&&dsec==1){
    document.forms.count.count2.value=current
    return
    }
    if(yr==0&&m==0&&d==0){
    document.forms.count.count2.value=none
    return
    }
    if(dday<0){
    document.forms.count.count2.value=past
    return
    }

    else
    document.forms.count.count2.value="Only "+dday+ " days until "+before+ " "+m+ "/"+d+ "/"+yr
    setTimeout("countdown(theyear,themonth,theday)",1000)
    }
    //enter the count down date using the format year/month/day
    countdown(2012,6,10)
    </script>
    </span></font>

  7. #7
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Lookalike the problem is no quotation marks, try:
    Code:
     var past="<a href = "reunion-1965.php"> <b>Class of 1965 - There is no reunion information available.</b></a>"
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  8. #8
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Still no go :(

    I tried that also.

    I tried placing the "'s at the begining and the end. And what I got was
    <a href = reunion-1965.php> <b>Class of 1965 - There is no reunion information available.</b></a> showing in the field box.

    I also tried placing the "'s like this "Class of 1965 - There is no reunion information available." in the line and then I got nothing again.


    Am I to assume that you can not have a link inside of a form box??

    Assuming that anything placed inside the quotes of the variable is output as it is and not run as code.

  9. #9
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    I think I get it now, the problem is that the code isn't actually being written to a place where the HTML tags can function correctly, so only text will work.
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  10. #10
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default So my assumption is correct.

    Yes Bernie.

    I now assumke that I was right that since the information is being inserted into a form box that the HTML code will not work.

    I thought I had seen this done somewhere before where it worked. I searched but can't find where or how it was done

Bookmarks

Posting Permissions

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