Randy webb and others

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard

    #1

    Randy webb and others

    Ok. I've quoted the inner stuff as needed.
    When I click on the "form" {no errors} all I get is a momentary whiteout of
    the saturn image and the saturn image returns intact.
    No image swapping, no text is written.
    Now what?


    <script type="text/javascript">

    function changeImage(ima geName,imageSou rce,divName,div Text){
    document.images[imageName].src=imageSourc e;
    document.getEle mentById(divNam e).innerHTML = divText;
    }


    </script>

    <form action="#">
    <input type="image" src="images/thmb001.jpg" value="101"
    onclick="change Image('main','i mages/thmb002.jpg','s ample','hello') ">
    </form>

    <div id="sample" >

    <img src="images/saturn.gif" name="main">


    </div>


  • Randy Webb

    #2
    Re: Randy webb and others

    Richard wrote:[color=blue]
    > Ok. I've quoted the inner stuff as needed.
    > When I click on the "form" {no errors} all I get is a momentary whiteout of
    > the saturn image and the saturn image returns intact.[/color]

    You should read Richard Cornford's reply to your last thread. Stop using
    a submit button for something other than what it was intended to do -
    submit a form. If you test your page again, after the saturn image
    returns intact, you should notice that the URL has changed and has a #
    appended to the end of it. If it were not for the form submission, you
    would see the text but no image.
    [color=blue]
    > No image swapping, no text is written.[/color]

    Yes it is.
    Image gets changed.
    innerHTML gets changed (removing the img tag).
    Form gets submitted.
    Page returns unchanged (except the URL has # appended to it).
    [color=blue]
    > Now what?[/color]

    First, you change the input type="image" to a link/image. Then, you get
    the image out of the div tag.
    [color=blue]
    > <script type="text/javascript">
    >
    > function changeImage(ima geName,imageSou rce,divName,div Text){
    > document.images[imageName].src=imageSourc e;
    > document.getEle mentById(divNam e).innerHTML = divText;
    > }[/color]

    If one wanted to get pedantic, that function lacks a lot of feature
    detection that I chose to leave out of it for fear that I may have to
    attempt to explain it to you.
    [color=blue]
    >
    > </script>
    >
    > <form action="#">
    > <input type="image" src="images/thmb001.jpg" value="101"
    > onclick="change Image('main','i mages/thmb002.jpg','s ample','hello') ">
    > </form>
    >
    > <div id="sample" >
    >
    > <img src="images/saturn.gif" name="main">
    >
    >
    > </div>[/color]

    <div id="sample"></div>
    <img src="images/saturn.gif" name="main" width="XX" height="XX"
    alt="----------">

    <a href="images/thmb002.jpg" target="_new"
    onclick="change Image('main',th is.href,'sample ','hello');
    return false">
    <img src="images/thmb002.jpg" border="0" width="XX" height="XX"
    alt="----------">
    </a>

    There is a reason that I put the width, height and alt attributes in the
    image tag. I will leave it up to you to attempt to discover what they
    are for.

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq

    Comment

    • MikeB

      #3
      Re: Randy webb and others

      Isn't this is the third thread in as many days on the same stuff?.


      Comment

      • Randy Webb

        #4
        Re: Randy webb and others

        MikeB wrote:[color=blue]
        > Isn't this is the third thread in as many days on the same stuff?.[/color]

        Ayup. And if we are lucky it will take less than 38 threads for RtS to
        grasp the concept.

        --
        Randy
        comp.lang.javas cript FAQ - http://jibbering.com/faq

        Comment

        • Richard

          #5
          Re: Randy webb and others

          Thanks for the assistance randy.
          With your clues, I actually found a simple script that works just the way I
          wanted.
          Somewhat similar to your input, but a little easier for me to understand and
          follow.
          All I need to do now is figure out how to add the text and I'm in business.

          So maybe tonight I'll have it online.

          Thanks for the help.



          Comment

          • MikeB

            #6
            Re: Randy webb and others


            "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
            news:xYqdnRo58s tc-WDcRVn-vg@comcast.com. ..[color=blue]
            > MikeB wrote:[color=green]
            > > Isn't this is the third thread in as many days on the same stuff?.[/color]
            >
            > Ayup. And if we are lucky it will take less than 38 threads for RtS to
            > grasp the concept.[/color]

            I wouldn't hold my breath..

            The OPs "With your clues, I actually found a simple script that works" misses
            the mark of what a "Programmin g Language" encapsulates.

            The Idea of taking your (very own) concept and expressing what and how you want
            something to happen with your (very own) interpretation of it within the
            limitations of the programming language,seems to somehow have escaped the OP.

            You have been too kind and verrryyy patient...
            [color=blue]
            > --
            > Randy
            > comp.lang.javas cript FAQ - http://jibbering.com/faq[/color]


            Comment

            • Randy Webb

              #7
              Re: Randy webb and others

              Richard wrote:[color=blue]
              > Thanks for the assistance randy.[/color]

              Then please do me the favor of quoting what you are replying to.
              [color=blue]
              > With your clues, I actually found a simple script that works just the way I
              > wanted.
              > Somewhat similar to your input, but a little easier for me to understand and
              > follow.
              > All I need to do now is figure out how to add the text and I'm in business.[/color]

              To be honest, I don't see how it could get any simpler than what I gave
              you. Especially given your requests/requirements of what the script
              would do. But for my own use I would use an array (or just a plain
              object) and pass the reference number instead of all the text:


              <script type="text/javascript">

              var myArray = new Array()
              myArray[0] = new Array('newImage 0Name','divText 0')
              myArray[1] = new Array('newImage 1Name','divText 1')
              myArray[2] = new Array('newImage 2Name','divText 2')
              myArray[3] = new Array('newImage 3Name','divText 3')
              myArray[4] = new Array('newImage 4Name','divText 4')


              function changeImage(arr ayEntry){
              document.images['imageName'].src=myArray[arrayEntry][0];
              document.getEle mentById('divNa me').innerHTML = myArray[arrayEntry][1];
              }

              Where divName and imageName are the names of the image/div and
              hard-coded in the page.

              Then, you call it thus:

              onclick="change Image(0);return false"
              [color=blue]
              > So maybe tonight I'll have it online.[/color]

              Maybe.
              [color=blue]
              > Thanks for the help.[/color]

              Welcome.

              --
              Randy
              comp.lang.javas cript FAQ - http://jibbering.com/faq

              Comment

              Working...