SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Changing arrays

  1. #1
    SitePoint Enthusiast JCsuperstar's Avatar
    Join Date
    Mar 2005
    Location
    Many places.
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing arrays

    Hello,

    How do you change array values based on if..then statements?

    Ex.
    Code:
    if(radioObj[0].checked == true) {
    nPrice = new Array ("106.99" , "86.99" , "115.99" , "319.99" )
    }
    if(radioObj[1].checked == true) {
    nPrice = new Array ("89.99" , "74.99" , "102.99" , "239.99" )
     }
    Specifically, what is wrong with that above?

    Any help at all is appreciated,

    Colin

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    array

    Once you declare a "new" array, I don't think you can re-declare it new again. You can change the values with lines like
    nPrice[0] = "89.99";

  3. #3
    SitePoint Enthusiast JCsuperstar's Avatar
    Join Date
    Mar 2005
    Location
    Many places.
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been doing some research and I'm able to get the right function to call the right pricing when I change my radio button selection.

    But it resets the page and only writes the data rather than writing the data at the places I want it to on the same page. Why is this?

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    script

    If the function resets the other fields, you have to get their values and set them back to those values. If the function is using document.write you will get a screen with the output, not the page. You need to use something like
    Code:
    var price1 = document.getElementById('input1');
    price1.value = new_value;


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
  •