Simple programming, please help

Discussion in 'Programming' started by stompergames, Aug 6, 2008.

  1. #1
    I have been working on this issue with innerhtml.

    I am having the innerhtml submit onclick and transform into a link when a condition is met by the function. BUT it takes 1 click to activate the link from the innerhtml and ANOTHER click to actaully use the link.

    The function used is here for the onlick:

    function genoutput() {
    var s1 = document.getElementById('display1').value;
    var s2 = document.getElementById('display2').value;

    if(s1 == 1 && s2 == 5){
    document.getElementById('submit').innerHTML = '<a href="economical.html"><img src="images/submit.jpg" alt="submit" /></a>';
    }

    else{
    alert(s2);
    }

    }



    Is it possible to get this down so the user need only click once?

    Thanks
     
    stompergames, Aug 6, 2008 IP
  2. david_t

    david_t Member

    Messages:
    74
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #2
    As far as I can see the above code looks fine, can you perhaps give us a link to the entire page?
     
    david_t, Aug 6, 2008 IP
  3. JeffHood

    JeffHood Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you know the URL you can use the following one-liner to load it as the last step in the function:
    document.location='http://www.whatever.com';
     
    JeffHood, Aug 7, 2008 IP
  4. nhl4000

    nhl4000 Well-Known Member

    Messages:
    479
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    110
    #4
    I think the method JeffHood mentioned is best, if the one click is just going to redirect to a certain URL why waste time 'showing' the active link when you can just do document.location="URL" to the destination.
     
    nhl4000, Aug 7, 2008 IP