This should be simple but I just can't seem to figure it out.
I have a form with 2 checkboxes in it. Clicking either checkbox runs a
js function which opens a new window. The form targets that new
window.
How can I pass a hidden value letting the new window know which
checkbox was clicked?
Below is the code I'm currently using:
function JSCheckbox(Whic hForm) {
window.open('', "CheckboxWindow ", 'height=1,width =1');
document.getEle mentById(WhichF orm).submit();
}
<form id="FormCheckbo x1" method="post" action="checkbo x.php"
target="Checkbo xWindow">
<input type="hidden" name="TheRecID" value="1">
<input type=checkbox NAME="FlagDone" VALUE="1"
onclick="JSChec kbox('FormCheck box1');">
.... second checkbox
</form> 7 1673
FP said the following on 7/20/2006 4:26 PM:
This should be simple but I just can't seem to figure it out.
I have a form with 2 checkboxes in it. Clicking either checkbox runs a
js function which opens a new window. The form targets that new
window.
Hmmm. And if you just submit the form, guess what happens?
Yeah, it opens the window for you, gives it the name, and even passes
the form information.
How can I pass a hidden value letting the new window know which
checkbox was clicked?
Change the method of your form and get it from the querystring.
Or, have the PHP file return it into the page.
Below is the code I'm currently using:
function JSCheckbox(Whic hForm) {
window.open('', "CheckboxWindow ", 'height=1,width =1');
document.getEle mentById(WhichF orm).submit();
}
And I suppose you get a 1x1 window?
<form id="FormCheckbo x1" method="post" action="checkbo x.php"
target="Checkbo xWindow">
<input type="hidden" name="TheRecID" value="1">
<input type=checkbox NAME="FlagDone" VALUE="1"
onclick="JSChec kbox('FormCheck box1');">
.... second checkbox
</form>
That is a ridiculously dumb way to try to open a new window and target a
form to it. Sorry for the blunt response but it is.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote:
FP said the following on 7/20/2006 4:26 PM:
This should be simple but I just can't seem to figure it out.
I have a form with 2 checkboxes in it. Clicking either checkbox runs a
js function which opens a new window. The form targets that new
window.
Hmmm. And if you just submit the form, guess what happens?
Yeah, it opens the window for you, gives it the name, and even passes
the form information.
Alright, I suppose I should have clarified that the new window closes
itself again afterwards and I don't want the window that you're
origionally in to disappear or reload. I know you've already told me
to do this with iFrames but after spending an hour trying to figure out
how to make that work I figured I'll stick with my clunky way of
displaying a new window and having it run the required PHP code.
How can I pass a hidden value letting the new window know which
checkbox was clicked?
Change the method of your form and get it from the querystring.
Or, have the PHP file return it into the page.
When you say "Change the method of your form and get it from the
querystring" are you saying I should add which checkbox was clicked as
part of the URL?
Since both checkboxes submit the same form and call the same JS
function I don't know how to add which checkbox was clicked as part of
the information that is transfered to the processing page.
>
Below is the code I'm currently using:
function JSCheckbox(Whic hForm) {
window.open('', "CheckboxWindow ", 'height=1,width =1');
document.getEle mentById(WhichF orm).submit();
}
And I suppose you get a 1x1 window?
IE 5.2 on the Mac does, Safari & Netscape don't.
>
<form id="FormCheckbo x1" method="post" action="checkbo x.php"
target="Checkbo xWindow">
<input type="hidden" name="TheRecID" value="1">
<input type=checkbox NAME="FlagDone" VALUE="1"
onclick="JSChec kbox('FormCheck box1');">
.... second checkbox
</form>
That is a ridiculously dumb way to try to open a new window and target a
form to it. Sorry for the blunt response but it is.
I don't mind the blunt response, after 20 hours of playing with
javascript I don't know any better; what would be more helpfull is the
correct way to do this.
So how would you do the following;
- the processing has to take place in a new window without
disrupting the current window
- the processing window has to know what checkbox was clicked
- there are other hidden fields that are passed
FP said the following on 7/20/2006 5:36 PM:
Randy Webb wrote:
>FP said the following on 7/20/2006 4:26 PM:
>>This should be simple but I just can't seem to figure it out. I have a form with 2 checkboxes in it. Clicking either checkbox runs a js function which opens a new window. The form targets that new window.
Hmmm. And if you just submit the form, guess what happens? Yeah, it opens the window for you, gives it the name, and even passes the form information.
Alright, I suppose I should have clarified that the new window closes
itself again afterwards and I don't want the window that you're
origionally in to disappear or reload.
And it will still do that if you just submit the form and have the
loading page close itself. But life is simpler than that.
I know you've already told me to do this with iFrames but after
spending an hour trying to figure out how to make that work I
figured I'll stick with my clunky way of displaying a new window
and having it run the required PHP code.
If your only need is to have a PHP script execute, you don't need the
IFrame or the new window. You only need them if you want some return
value from the PHP code.
>>How can I pass a hidden value letting the new window know which checkbox was clicked?
Change the method of your form and get it from the querystring. Or, have the PHP file return it into the page.
When you say "Change the method of your form and get it from the
querystring" are you saying I should add which checkbox was clicked as
part of the URL?
No, change the method from post to get and the browser will
automatically add it to the URL. But, have the PHP code read the
submitted form data. Your checkbox and hidden field values will be
available to it.
Since both checkboxes submit the same form and call the same JS
function I don't know how to add which checkbox was clicked as part of
the information that is transfered to the processing page.
The browser does it for you. Try it. The PHP page will have access to
the checked checkbox.
>
>>Below is the code I'm currently using:
function JSCheckbox(Whic hForm) { window.open('', "CheckboxWindow ", 'height=1,width =1'); document.getEle mentById(WhichF orm).submit(); }
And I suppose you get a 1x1 window?
IE 5.2 on the Mac does, Safari & Netscape don't.
Nor any browser on a PC. The smallest window I recall being able to open
on a PC was 100x100 or so.
>><form id="FormCheckbo x1" method="post" action="checkbo x.php" target="Check boxWindow"> <input type="hidden" name="TheRecID" value="1"> <input type=checkbox NAME="FlagDone" VALUE="1" onclick="JSCh eckbox('FormChe ckbox1');"> .... second checkbox </form>
That is a ridiculously dumb way to try to open a new window and target a form to it. Sorry for the blunt response but it is.
I don't mind the blunt response, after 20 hours of playing with
javascript I don't know any better; what would be more helpfull is the
correct way to do this.
Fair enough.
So how would you do the following;
- the processing has to take place in a new window without
disrupting the current window
Actually, it doesn't. You can do it in the same window without
disrupting it.
- the processing window has to know what checkbox was clicked
It does if the form is submitted.
- there are other hidden fields that are passed
If you are not getting a return value from the PHP code, you can simply
set the .src of an Image Object to the string you need.
"How do I run a server side script?"
<URL: http://jibbering.com/faq/#FAQ4_34>
<iframe name="myIFrame" style="width:0p x;height:1px;"> </iframe>
target="window. frames['myIFrame']"
And submit your form....
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy,
I assume there is something very basic I'm not understanding here.
Previously I had 2 forms;
- 1 form for checkbox Done
- 1 form for checkbox Monitor
Both forms called the same HTML page and submitted the hidden value
"RecID" and "CheckboxClicke d", however CheckboxClicked had either the
value "Done" or "Monitor".
These forms were submitted to an html page which just had the PHP code:
....
if($_REQUEST['CheckboxClicke d']=='Done'){
//toggle database value for flagdone
}else{
//toggle database value for flagmonitor
}
I'm trying to put both checkboxes in the same form because display wise
they're not lining up in older browsers. The problem is:
I don't know how to set "CheckboxClicke d" to "Done" or "Monitor"
depending on the checkbox the user clicked on.
Or if I have to have each checkbox call a different javascript
functions then I don't know how to set "CheckboxClicke d" from within
the javascript function.
If either of the above 2 is possible, could you please write out the
code that will do that.
Thanks in advance.
FP said the following on 7/20/2006 11:34 PM:
Randy,
I assume there is something very basic I'm not understanding here.
Yes, there is.
Previously I had 2 forms;
- 1 form for checkbox Done
- 1 form for checkbox Monitor
Both forms called the same HTML page and submitted the hidden value
"RecID" and "CheckboxClicke d", however CheckboxClicked had either the
value "Done" or "Monitor".
These forms were submitted to an html page which just had the PHP code:
....
if($_REQUEST['CheckboxClicke d']=='Done'){
//toggle database value for flagdone
}else{
//toggle database value for flagmonitor
}
OK, simple enough.
I'm trying to put both checkboxes in the same form because display wise
they're not lining up in older browsers. The problem is:
I don't know how to set "CheckboxClicke d" to "Done" or "Monitor"
depending on the checkbox the user clicked on.
<input type="checkbox" name="CheckboxC licked" value="Done">
<input type="checkbox" name="CheckboxC licked" value="Monitor" >
Now, when the form gets submitted, PHP will read the value of
CheckboxClicked and act accordingly. And, you don't even have to submit
the form to trigger the PHP script.
Or if I have to have each checkbox call a different javascript
functions then I don't know how to set "CheckboxClicke d" from within
the javascript function.
Neither.
If either of the above 2 is possible, could you please write out the
code that will do that.
The first is simple, the second is like using a sledgehammer to drive a
finishing nail in. Its overkill.
What you want to do is this simple:
function runPHPScript(ra dioButton){
//code below copied from the FAQ and modified
var dummyImage = new Image();
dummyImage.src= "scriptURL.php? "+radioButton.n ame+'='+radioBu tton.value;
//replace scriptURL.php with the path to your php script
}
<input type="radio" name="CheckboxC licked" value="Done"
onclick="runPHP Script(this)">
<input type="radio" name="CheckboxC licked" value="Monitor"
onclick="runPHP Script(this)">
I will let you ponder on why I changed them to radio buttons instead of
checkboxes (It works the same with either though).
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote:
<input type="checkbox" name="CheckboxC licked" value="Done">
<input type="checkbox" name="CheckboxC licked" value="Monitor" >
In the results page I was trying to figure out which checkbox was
clicked and update only it, now it finally occurred to me that it
doesn't matter which one was clicked, just update both. That was a
very stupid mistake and I understand why you didn't get the question I
was trying to ask.
Now, when the form gets submitted, PHP will read the value of
CheckboxClicked and act accordingly. And, you don't even have to submit
the form to trigger the PHP script.
I'm also new to PHP so I don't want to get into PHP scripts at this
point.
I will let you ponder on why I changed them to radio buttons instead of
checkboxes (It works the same with either though).
FlagDone is suppose to be completely independant of FlagMonitor, but I
see why you said that.
You had said in a different post that I was submitting the data in a
bad way by having a function open a new window and posting into it from
the form. I tried to modify my code and currently have;
<form method="post" action="donemon itor.php" target="WinDone Monitor"
onsubmit="windo w.open('donemon itor.php', 'WinDoneMonitor ', 'height=100
width=100');">
This works, new window opens, record is updated, window closes itself.
Only the height & width is not respected, how do I make that work?
Thanks again for your help so far.
FP said the following on 7/21/2006 2:28 PM:
Randy Webb wrote:
<snip>
>Now, when the form gets submitted, PHP will read the value of CheckboxClicke d and act accordingly. And, you don't even have to submit the form to trigger the PHP script.
I'm also new to PHP so I don't want to get into PHP scripts at this
point.
Ya gotta start somewhere, may as well be here.
>I will let you ponder on why I changed them to radio buttons instead of checkboxes (It works the same with either though).
FlagDone is suppose to be completely independant of FlagMonitor, but I
see why you said that.
Change them to checkboxes, give them different names, and test the code....
You had said in a different post that I was submitting the data in a
bad way by having a function open a new window and posting into it from
the form.
Yes, because its a bad way to do it.
I tried to modify my code and currently have;
<form method="post" action="donemon itor.php" target="WinDone Monitor"
onsubmit="windo w.open('donemon itor.php', 'WinDoneMonitor ', 'height=100
width=100');">
This works, new window opens, record is updated, window closes itself.
It "works" only if the window.open call is honored. It may not be,
depending on the popup blocker.
Only the height & width is not respected, how do I make that work?
Use the code I gave you, test it, then stop trying to open a new window
and the height and width won't matter.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jason |
last post by:
Hello and Good day.
There's a site I want to link to passing info I collect without having
to re-enter the data on that's sites input form. I know this is not
always possible, but in this case want to make sure it's not code. The
site renders a Sat image when fed address.
To manually get to the form go to :
imageatlas.globexplorer.com
and enter a valid address and hit FIND IT.
|
by: Don |
last post by:
I have a need to submit a form, but don't need the user to click on a button. How do I do this? Is
there some way, using JavaScript, to setup a <form> tag to do this?
Thanks,
Don
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
|
by: Manfred Bauer |
last post by:
Dear all,
I have written an ASP.NET application using NT-Authentfication against an
Active Directory domain. Users that are logged on have access to an Outlook
Web Access site, also using NT-Authentfication (and running on the same
machine). Because OWA is implemented as website (not virtual folder) in IIS,
my users get the logon-dialog-box twice: first, when they log on to my
website, and afterwards when they want to use Outlook Web...
|
by: Syam |
last post by:
Hello everyone,
I am just barely two months old into learning asp.net and vb.net. Currently
I am working on a project to store customer database. I have a question about
creating a preview page:
I have a main page that uses forms to input customer information such as
name, contacts etc... Once all information is filled up, I would like to
preview it irst before submitting to the database. On the main page, there
should be a preview...
|
by: Barkster |
last post by:
I registered for this service and when I put my username it looked up
the username without submitting and told me it was taken after leaving
the field. Any ideas on how they are doing it
http://forums.oscommerce.com/index.php?act=Reg&CODE=00 use username:
barkster to test
Thanks
| |
by: varun |
last post by:
Hi,
I am using goahead webserver...i have a form, in acction attribute i am
calling a c function..
after submitting the form i need to close the window and i need to
reload the window which navigated to this window.....
i used this javasript .......
function doUnLoad()
|
by: browntown |
last post by:
so I have this application I'm nearly finished with. The only thing the
client has requested is the ability to submit the form by pressing
"enter". I didn't think this would be a huge pain in the ass and the
app will be used internally so I'm not too worried about users who
aren't using javascript. I'm using the following javascript to detect
whether or not they've hit enter:
if(document.layers)
{
|
by: veronicab |
last post by:
Hi all,
I have a page with a very large form. When user clicks on the button to submit the form, page "freezes" for several seconds, and then finally you notice it was not frozen but just submitting the lots of info, since it loads the form-action page.
I can't change the form design. User wants the page organized in tabs, and the whole form submitted when user presses Save button. So the form size seems like something I cannot change.
...
|
by: asp beginner |
last post by:
I am building an Eccomerce site and I am trying to make my shopping cart work. I am having a problem with when I have entered data into my form it is not submitting into my access database. This my coding for my page. I am very new at all this and any help with be most appreciated.
<%@ Page Language="vb" Debug="True"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Drawing" %>...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |