1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

javascript return value problem

Discussion in 'JavaScript' started by tech_tycoon, Aug 25, 2010.

  1. #1
    Hello all,

    I have to take return value from different from different page.

    I have a page (page_1.php) with a form.I have to select an image name from pop page(page_2.php).When page_2.php page open many images are opened.When i will select any random image , the imagetextbox should be filled by that selected image name without refreshing page_1.php.
     
    tech_tycoon, Aug 25, 2010 IP
  2. tdemetri

    tdemetri Peon

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hi - i am trying to understand your request. if it could be stated more clearly, it will be easier to help you.

    if you want to pass a value from a form on one page to something on another page, this can easily be accomplished by using a cookie to pass a form value from one page to another


    are you talking about the images on page 1 ? there doesn't need to be any refresh. you can add text to a selected image many different ways, all without going back to the server. one easy way: each image's name is passed to the click function . a simple function can fill a text box with the name of a clicked/selected image.
    example:
    
    <head>
    <script type="text/javascript">
    function revealName(nam){
    document.getElementById("textbox").value=nam	
    }
    </script>
    </head>
    
    <body>
    <input type="text" id="textbox" />
    <img src="pic1.jpg" name="picture one" onclick="revealName('picture one')" />
    <img src="pic2.jpg" name="image number 2" onclick="revealName('image number two')" />
    
    </body>
    
    Code (markup):
    hope i understood your request correctly, and if so, hope this helps
     
    tdemetri, Aug 25, 2010 IP
  3. tech_tycoon

    tech_tycoon Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I may be i am not able to explain my query.
    But i am trying it again.

    page_1.php has a form with one textbox and one button.When user is clicking on button a popup windows is opening that is page_2.php.This page_2.php has lsit of images when user is clicking on any image that image name is filling textbox value by the clicked image name.This should be by javascript.becz page_1.php should not refresh.

    thanks
     
    tech_tycoon, Aug 25, 2010 IP
  4. hdewantara

    hdewantara Well-Known Member

    Messages:
    541
    Likes Received:
    47
    Best Answers:
    25
    Trophy Points:
    155
    #4
    Probably showing some of your script here,
    would help us understand better.

    My guess is that it's a process before form submission?

    So your popup page_2 look like:
    <a href="javascript:void(0)" onclick="report(this)"><img src="water.jpg" style="background-color:#faa;" alt="water"/></a>
    <a href="javascript:void(0)" onclick="report(this)"><img src="fire.jpg" style="background-color:#afa;" alt="fire"/></a>
    <a href="javascript:void(0)" onclick="report(this)"><img src="soil.jpg" style="background-color:#aaf;" alt="soil"/></a>
    
    HTML:
    To report to opener page, this popup uses report() function:
    <script type="text/javascript">
      function report(a){
        opener.document.getElementById("img_name").value = a.childNodes[0].src;
      }
    </script>
    Code (markup):
    where img_name is the id of textbox on opener page_1:
    <form>
      <input id="img_name" type="text" />
    </form>
    
    HTML:
    Remember though, that not all browsers like popup window,
    and your popup would be opened in browsers tab.
    Opening an iframe is a better,
    but these two require same domain rule to work.

    Just a layer div, is much better.

    Hendra
     
    hdewantara, Aug 26, 2010 IP