Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Button Link to another page through JavaScript

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #168632
    cyclingg
    Participant

    I know you can link to another page through HTML.

    I am creating a table using JavaScript. I am using arrays to place all the rows and cells.

    In one of my cells for each row, I created a button (in my javaScript array). I would like to go to an id name on another page when you click this button. I cannot seem to add a link to the button. I can do this when using HTML and CSS; but, not with javaScript. I can also get this working when I just link my text from the table to my page (using javaScript). I do not want to know how with jQuery or Ajax or php; I am trying to learn javaScript at the moment.

    Is this possible?

    Here is an example of what I am trying to do:
    I only added the button input for one of the elements.

    //initialize and set up the 'bookButtons' array
    var bookButtons = new Array();
    bookButtons[0] = "<input type='button' id='htmlcss' value='Shop Similar'>";
    bookButtons[1] = "JavaScript";
    bookButtons[2] = "Photoshop";
    bookButtons[3] = "Painter";
    bookButtons[4] = "Digital Painting"; 
    

    I tried adding an onclick statement at the end after ‘shop similar’ with a link to my other page. It did not work. Am I totally out to lunch?

    Thanks.

    #168641
    cyclingg
    Participant

    Hi TheDoc

    I want a button.

    I found a way I might be able to do this. It is with onClick = “document.location = ‘somefile.htm#someId’ “.

    I have not used “document.location yet. I will try it later tonight.

    #168654
    Paulie_D
    Member

    …or just use a <button>

    #168716
    cyclingg
    Participant

    I decided to just use my images as links. The button idea did not work.

    I did not want to use an image of a button; that is not the point of this exercise. I know how to use images as links.

    I am taking a JavaScript course and our assignment was on Arrays. I made a table using JavaScript and wanted a button to be used as a link. It did not work; I made the button but it would not link out. It is not a requirement for this assignment; so, I am using my images as links.

    Thanks.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.