SitePoint Sponsor

User Tag List

Results 1 to 17 of 17
  1. #1
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onclick event. Do I need quotes here...

    Hey, this is the code (kinda) from one of my forms:

    Code:
    <form name="submit1">
    ...
    <input type="text" name="text">
    <input type="button" name="verify" value="Verify" onClick="window.open('test.' + document.submit1.text.value ,'location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no' )" style="font-size: 8pt; font-family: Verdana; height: 21; width: 53">
    ...
    </form>
    I cant get it to work because + document.submit1.text.value is just sitting there withought quotes. What can i do to fix that? Thanks,
    Mike
    It's not who I am underneath, but what I do that defines me.

  2. #2
    SitePoint Zealot jonsteele's Avatar
    Join Date
    Jan 2001
    Location
    Toronto
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I am guessing right, you are trying to open the value of the text box, in that case
    Code:
    onClick="window.open('test', document.submit1.text.value ,'location=no,menubar...

  3. #3
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually, I'll be opening a php page with the value of the selected textbox item as a variable.

    I was just playing tith the script so that i would open an html page named test.htm (htm would be the value)

    Code:
    <input type="button" name="verify" value="Verify" onClick="window.open('verifycat.php?cat=' + document.submit1.comp_category.value)" style="font-size: 8pt; font-family: Verdana; height: 21; width: 53">
    Mike
    It's not who I am underneath, but what I do that defines me.

  4. #4
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just need to know how to fit the other options into it (scrollbars, resizable...)
    Mike
    It's not who I am underneath, but what I do that defines me.

  5. #5
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?
    Mike
    It's not who I am underneath, but what I do that defines me.

  6. #6
    SitePoint Zealot jonsteele's Avatar
    Join Date
    Jan 2001
    Location
    Toronto
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should work:


    onclick="window.open('','verifycat.php?cat=' + document.submit1.comp_category.value+'','scrollbars=no,etc.')"

  7. #7
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by jonsteele
    This should work:


    onclick="window.open('','verifycat.php?cat=' + document.submit1.comp_category.value+'','scrollbars=no,etc.')"
    What do the two '' do?
    Mike
    It's not who I am underneath, but what I do that defines me.

  8. #8
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just tried it, no luck
    Mike
    It's not who I am underneath, but what I do that defines me.

  9. #9
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll need to concatenate the two strings into a new variable before using them in the function.

  10. #10
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, thanks matt I'll go get a dictionary so I know what that means
    Mike
    It's not who I am underneath, but what I do that defines me.

  11. #11
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I got it working. I'd just like to send a big shout-out and thanks to Wavelan for sending me the code
    Mike
    It's not who I am underneath, but what I do that defines me.

  12. #12
    SitePoint Zealot jonsteele's Avatar
    Join Date
    Jan 2001
    Location
    Toronto
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    care to share

  13. #13
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script type="text/javascript">
    <!--
    function openwin(){
    
    var cat = "mypage.php?cat=";
    var cat2 = document.formname.formfield.value;
    var cat3 = cat + cat2;
    
    window.open('cat3','category','scrollbar=0,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
    document.close();
    
    }
    //-->
    </script>
    
    
    <input type="button" name="verify" value="Verify" onclick="openwin()">
    Mike
    It's not who I am underneath, but what I do that defines me.

  14. #14
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by naramation
    Code:
    <script type="text/javascript">
    <!--
    function openwin(){
    
    var cat = "mypage.php?cat=";
    var cat2 = document.formname.formfield.value;
    var cat3 = cat + cat2;
    
    window.open('cat3','category','scrollbar=0,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
    document.close();
    
    }
    //-->
    </script>
    
    
    <input type="button" name="verify" value="Verify" onclick="openwin()">
    shouldn't cat3 be without quotes

  15. #15
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think so, but I don't know much js, thats why i posted here

    It does work with quotes though. I'll try without.
    Mike
    It's not who I am underneath, but what I do that defines me.

  16. #16
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you have it in quotes, the url will be cat3, but without them it will show the url any way i'd do it a bit differently anyway.

    var cat = "mypage.php?cat=";
    var cat2 = document.formname.formfield.value;
    var cat3 = cat + cat2;

    PHP Code:
    <script type="text/javascript">
    <!--
    function 
    openwin()
    {
      
    window.open('mypage.php?cat=' document.formname.formfield.value,'category','scrollbar=0,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
      
    document.close();
    }
    //-->
    </script> 

  17. #17
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried that in the onclick right in the button, but it didn't work

    window.open('mypage.php?cat=' + document.formname.formfield.value,'category','scrollbar=0,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');


    Is there a problem with wavelan's code, other than the quotes?
    Mike
    It's not who I am underneath, but what I do that defines me.


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
  •