Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript Idiot Needs Help!

    I am developing a website using PHP and I need to use Javascript to open a new window as well as submit information from a pull down menu to the newly created window. The new window needs to be opened where I can control the size of it automatically, rather than have the user resize it. My problem is that the user has to make a selection from a pull-down menu and the Go button doesn't post the variable from that menu to the item.enter.php. Can I get Javascript to submit the value to the new window?

    Code:
    <form name="form2" method="post" action="">
    <input name="name" type="hidden" id="name" value="<?=$name?>">
    <select name="item" id="item">
       <option selected>Choose an Item</option>
       <option value="A">A</option>
       <option value="B">B</option>
       <option value="C"></option>>
    </select>
    <input type="submit" name="Submit" value="Go" onClick="window.open('item.enter.php?item=<?=$item?>&name=<?=$name?>','<?=$item?>,'width=400,height=300')">
    </form>

  • #2
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    Code:
     
    <form name="form2" method="post" action="">
    <input name="name" type="hidden" id="name" value="<?=$name?>">
    <select name="item" id="item">
       <option selected>Choose an Item</option>
       <option value="A">A</option>
       <option value="B">B</option>
       <option value="C"></option>>
    </select>
    <input type="button" name="Submit" value="Go" onClick="window.open('item.enter.php?item=' + document.getElementById('item').value + '&name=' + document.getElementById('name').value,document.getElementById('item').value,'width=400,height=300')">
    </form>
    also note that name and submit are probably not good choices for an ids/names... so maybe change that to something else
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • Users who have thanked mjlorbet for this post:

    thebarless (04-23-2008)

  • #3
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up

    awesome...works like a charm. thanks for your help. many cans of pabst blue ribbon (my beer of choice) to you.

    btw- the vars match my db names...so i just modded them on here for sake of reading ease. thanks again

  • #4
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    okay, i have a quick problem. if i try to open multiple windows under the same item, it refreshes in that item's window, though if i open multiple windows under the same user, it opens separate windows. i essentially need this backwards...so that I can have 10 users with 1 item...but one user can access only one item at a time.

    ---
    nevermind. i started playing...figured out to change the last getElementById and it works good. kick ***...VAB. yes...ASVAB.
    Last edited by thebarless; 04-23-2008 at 03:26 AM.

  • #5
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    Code:
     
    <script type="text/javascript">
    var windex = new Array();
    </script>
    change your onclick to:

    Code:
     
    windex.push(window.open('item.enter.php?item=' + document.getElementById('item').value + '&name=' + document.getElementById('name').value,document.getElementById('item').value,'width=400,height=300')");
    this will create a different entry in the array of opened windows for each window opened
    Last edited by mjlorbet; 04-23-2008 at 01:19 PM.
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender


  •  

    Posting Permissions

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