Results 1 to 3 of 3
- 07-29-2009, 11:02 AM #1
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
need to adjust a code I have to work with hidden fields
I'm building a form where staff can process quotes. I have a database with products and I need a button in the form to open a new window. In the new window you'd search for your product and choose it. Then I'd like to have a button when after I've clicked it, product code will be filled in the original form and the new window would close.
This is the code I have that I modified from a code that let you select a value from a select field. Unfortunately it doesn't work. I think the problem is in the head of the child file. I look forward to your comments.
parent file (parts of it):
Java Code://head: <script type="text/javascript"> targetElement = null; function addProduct(frm, id) { if(!frm || !id) return; targetElement = frm.elements[id]; var handle = window.open('find_product.php'); } </script> //body: <form id="frm" name="frm" action="#"> <input name="code" type="text" id="code" size="10" /> <input name="name" type="text" id="name" size="32" /> <input type="button" value="Add Item" onclick="addProduct(this.form, 'code');" /> </form>
child file (parts of it):
Java Code://head: <script type="text/javascript"> function addProduct(frm, id) { if(!frm || !id) return; var elem = frm.elements[id]; if(!elem) return; var val = elem.options[elem.selectedIndex].value; opener.targetElement.value = val; this.close(); } </script> //body: <form id="frm" name="frm" action="#"> <input name="code" type="hidden" value="<?php echo $row_rsProducts['ProductID']; ?>" /> <input name="name" type="hidden" value="<?php echo $row_rsProducts['ProductName']; ?>" /> <input type="button" value="Add Product" onclick="addProduct(this.form, 'code');" /> </form>
Another thing that I'm not sure how to go round is that forms can't be nested so after the field is filled in, how can I submit the value? I'd like to use this same field for another form.
- 07-29-2009, 11:45 AM #2
Member
- Join Date
- Jul 2009
- Posts
- 35
- Rep Power
- 0
Too hard to tell what your code is trying to do. All I can even see are two forms and what appears to be useless JS bar opening a PHP file. Either way what you are after could easily be done with some PHP/simple JS by posting the results back to the page and probably using Ajax I guess to refresh it with the values. If you are taking code you're probably better off keeping it all in one file.
But yeah, this is a Java forum and not a JS/PHP forum so I think your thread will be closed.
- 07-29-2009, 12:23 PM #3
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Running .java-files won't work/compile does!(Code inside)
By wyldstyle in forum New To JavaReplies: 6Last Post: 02-06-2009, 08:05 PM -
how does this code work...explain me the execution please...
By vital parsley in forum New To JavaReplies: 3Last Post: 07-25-2008, 04:50 AM -
the code dosent work
By pcman in forum Java 2DReplies: 1Last Post: 03-20-2008, 08:20 PM -
Jsp / Java cannot get fields
By Dracos in forum New To JavaReplies: 0Last Post: 02-04-2008, 09:39 PM -
How To:Use a JSlider to adjust Text size in a JPanel
By louiebagz in forum AWT / SwingReplies: 2Last Post: 07-01-2007, 07:37 AM


LinkBack URL
About LinkBacks

Bookmarks