www.webdeveloper.com
Results 1 to 10 of 10

Thread: getElementById Sound Simple enough!

  1. #1
    Join Date
    Feb 2011
    Posts
    6

    getElementById Sound Simple enough!

    Hey all,

    This is my first post on this site and it will not be the last I can tell you, I am going mad here as I know I have made this issue that I have working the past but for the life of me I cannot find the page with the code on.

    The issue is:

    I have a form field called productColour it has an id of productColour1 I am trying to reference the value of that field when the user clicks on an images button like so:

    Input Field:
    <input type="text" name="productColour" id="productColour1">

    Button:
    <input type="button" name="imagePopUp" value="Images" onClick="window.open('/admin/imageControl/index.cfm?productColour=document.getElementById("productColour1").value;');">

    As you see the javascript is supposed to capture the value in the productColour field append it on to the end of the url query string.

    I have tried everything I can think of and now I am off to find a brick wall to smash my head on to.

    I hope that someone more knowledgeable than me could shed some light problem.

    Mark

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    A referential value is not a string.
    Wouldn't be better to call a function, instead?
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    function openWin(id){
    window.open("/admin/imageControl/index.cfm?productColour=+document.getElementById(id).value+","");
    }
    </script>
    <body>
    <form action="">
    <input type="text" id="productColour1" value="boo">
    <input type="button" name="imagePopUp" value="Images" onclick="openWin('productColour1')">
    </form>
    </body>
    </html>
    Last edited by Kor; 02-28-2011 at 03:57 AM.

  3. #3
    Join Date
    Feb 2011
    Posts
    6

    Like your thinking!

    KOR

    I like your thinking and it would make the code much neater however I have tried it and it does not work the value of the productcolour1 field is not being displayed just the javascript:

    productColour=+document.getElementById(id).value+

    this is the query sting displayed on the called page, I have tried this on the page and with a new document.

    Mark

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Try
    Code:
    window.open("/admin/imageControl/index.cfm?productColour="+document.getElementById(id).value+"","");

  5. #5
    Join Date
    Feb 2011
    Posts
    6

    Thumbs up Yes it's works

    Kor

    thankyou you for your help, it's people like yourself that make the world a better place.

    I have lost a whole day on this myself now I can get back on tracks

    Your'a Star!!

    Mark

  6. #6
    Join Date
    Feb 2011
    Posts
    6
    Kor

    I have been playing with the code you kindly sent over and I have been adding more functionality to it I do have one issue that I cannot work out and hoped you may know what to do. Can I add attributes like height and width of the opened window as you do in a normal window.open().

    Regards

    Mark

  7. #7
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by activecommerce View Post
    Kor

    I have been playing with the code you kindly sent over and I have been adding more functionality to it I do have one issue that I cannot work out and hoped you may know what to do. Can I add attributes like height and width of the opened window as you do in a normal window.open().

    Regards

    Mark
    Could be:
    http://www.quirksmode.org/mobile/viewports.html

    But it would be somehow unpleasant for the user. Most of the people use TABS now within the same browser. Modifying the window's size will modify the whole browser. Well, you can try

  8. #8
    Join Date
    Feb 2011
    Posts
    6
    Sorry Kor I am not with you:

    This is the final code the works fine:

    (1) window.open("/admin/imageControl/index.cfm?productColour="+document.getElementById(id).value+"","");

    What i wish to do is set the width and height on the window that will be opened e.g.

    (2) onclick="window.open(("/admin/imageControl/index.cfm','testpopup','width=300,height200');

    how can I enter the width and height info in the window.open (1) code.

    Sorry If I am being think.

    Regards

    Mark Bryden

  9. #9
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    ah, sorry, I must have misunderstood your question

    Do you want to add dynamically the values?

  10. #10
    Join Date
    Feb 2011
    Posts
    6
    Kor

    I want manually add the height and width attributes to the open window script

    window.open("/admin/imageControl/index.cfm?productColour="+document.getElementById(id).value+"","");

    Where in the above code can I manually put these variables

    Width=300
    height=400

    Regards

    Mark

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles