...

View Full Version : Javascript Idiot Needs Help!



thebarless
04-23-2008, 02:22 AM
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?


<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>

mjlorbet
04-23-2008, 02:29 AM
<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

thebarless
04-23-2008, 02:35 AM
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

thebarless
04-23-2008, 03:14 AM
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.

mjlorbet
04-23-2008, 03:23 AM
<script type="text/javascript">
var windex = new Array();
</script>


change your onclick to:



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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum