| View previous topic :: View next topic |
| Author |
Message |
itunes66
Joined: 09 Mar 2005 Posts: 184
|
Posted: Mon Apr 11, 2005 10:57 am javascript function and forms problem |
|
|
|
i am trying to open a certain window whenn a form is submited but i cant figure it out here is the page code
| Code: |
<SCRIPT language="JavaScript">
// set functions to open the invitory and alert and/or change the options
function Jelly(jelly_id) {
if(jelly_id == "5"){
alert("no other jelly types allowed");
document.jelly.jelly_id.selectedIndex = 1;
}
}
function Jelly(jelly_id) {
if(jelly_id == ""){
document.jelly.jelly_id.selectedIndex = 1;
}
}
</SCRIPT>
</SCRIPT>
<FORM action="" method="get" name="jelly" onSubmit="return validate(this);">
<SELECT name="jelly_id" onChange="Jelly(this.value)">
<OPTION value="">Choose One</OPTION>
<OPTION value="0">strawberry jelly</OPTION>
<OPTION value="1">blueberry jelly</OPTION>
<OPTION value="2">pineapple jelly</OPTION>
<OPTION value="3">lime jelly</OPTION>
<OPTION value="4">glowing jelly</OPTION>
<OPTION value="5">other</OPTION>
</SELECT>
<input type="submit">
</FORM>
|
|
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Mon Apr 11, 2005 1:40 pm |
|
|
|
How do you plan to open the window?
Are you submitting to a page or using javascript window.open
and how the the option values releate to the window to open? |
|
itunes66
Joined: 09 Mar 2005 Posts: 184
|
Posted: Mon Apr 11, 2005 1:45 pm |
|
|
|
i am going to use javascript to open the window and i am going to use a free form service to submit it to my email adress and the values dont relate to any thing
BUT
1.i want the button to open the window and then you have to click it again to submit it
if it is almost impossible then read below
should i use php and if so what php should i use |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Mon Apr 11, 2005 1:51 pm |
|
|
|
You want to click the Submit button the first time to open the Window, then click it a second time to Submit the form?
or are you happy to have both happen at the same time? |
|
itunes66
Joined: 09 Mar 2005 Posts: 184
|
Posted: Mon Apr 11, 2005 2:00 pm |
|
|
|
| degsy wrote: |
You want to click the Submit button the first time to open the Window, then click it a second time to Submit the form?
or are you happy to have both happen at the same time? |
i want it to open the window first
hope this is not much work |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Mon Apr 11, 2005 2:23 pm |
|
|
|
If you just want to open a window then you can use onclick
| Code: |
<input type="submit" onclick="window.open('http://www.google.com');">
|
|
|
itunes66
Joined: 09 Mar 2005 Posts: 184
|
Posted: Mon Apr 11, 2005 2:30 pm |
|
|
|
yes i know but there is a reason i want it to open a window on the first click
and submit on the second
if they dont have the item i am wanting then
they dont have to submit but i do not want to use 2 buttons |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Mon Apr 11, 2005 2:52 pm |
|
|
|
You can use an onchange script on the select
| Code: |
<SCRIPT language="JavaScript">
// set functions to open the invitory and alert and/or change the options
function Jelly(jelly_id) {
if(jelly_id == "5"){
alert("no other jelly types allowed");
document.jelly.jelly_id.selectedIndex = 1;
return false;
}
if(jelly_id == ""){
document.jelly.jelly_id.selectedIndex = 1;
alert("Choose an item");
return false;
}
}
</SCRIPT>
</SCRIPT>
<FORM action="" method="get" name="jelly">
<SELECT name="jelly_id" onchange="Jelly(document.jelly.jelly_id.options[document.jelly.jelly_id.selectedIndex].value)">
<OPTION value="">Choose One</OPTION>
<OPTION value="0">strawberry jelly</OPTION>
<OPTION value="1">blueberry jelly</OPTION>
<OPTION value="2">pineapple jelly</OPTION>
<OPTION value="3">lime jelly</OPTION>
<OPTION value="4">glowing jelly</OPTION>
<OPTION value="5">other</OPTION>
</SELECT>
<input type="submit" onclick="window.open('http://www.google.com');">
</FORM>
|
|
|
itunes66
Joined: 09 Mar 2005 Posts: 184
|
Posted: Mon Apr 11, 2005 2:59 pm |
|
|
|
| why i need a button thingy to change |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Mon Apr 11, 2005 6:56 pm |
|
|
|
| itunes66 wrote: |
| why i need a button thingy to change |
I have no idea what you mean |
|
itunes66
Joined: 09 Mar 2005 Posts: 184
|
Posted: Tue Apr 12, 2005 4:15 am |
|
|
|
| ok i want a button to open a window when you click it the first time and to send the form you have to click it again |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Tue Apr 12, 2005 6:48 am |
|
|
|
| Code: |
<SCRIPT language="JavaScript">
// set functions to open the invitory and alert and/or change the options
function Jelly(jelly_id) {
if(jelly_id == "5"){
alert("no other jelly types allowed");
document.jelly.jelly_id.selectedIndex = 1;
return false;
}
if(jelly_id == ""){
document.jelly.jelly_id.selectedIndex = 1;
alert("Choose an item");
return false;
}
}
var popup = null
function checkSubmit(url){
if (popup != null){
//alert("submit");
document.jelly.submit();
}
else {
//alert("popup");
popup = window.open(url);
document.jelly.mySubmit.value ='Click Me Again';
return false;
}
}
</SCRIPT>
</SCRIPT>
<FORM action="" method="get" name="jelly">
<SELECT name="jelly_id" onchange="Jelly(document.jelly.jelly_id.options[document.jelly.jelly_id.selectedIndex].value)">
<OPTION value="">Choose One</OPTION>
<OPTION value="0">strawberry jelly</OPTION>
<OPTION value="1">blueberry jelly</OPTION>
<OPTION value="2">pineapple jelly</OPTION>
<OPTION value="3">lime jelly</OPTION>
<OPTION value="4">glowing jelly</OPTION>
<OPTION value="5">other</OPTION>
</SELECT>
<input name="mySubmit" type="button" id="mySubmit" onclick="checkSubmit('http://www.google.com');" value="Submit">
</FORM> |
|
|
itunes66
Joined: 09 Mar 2005 Posts: 184
|
Posted: Tue Apr 12, 2005 9:50 am |
|
|
|
it works
i love you LOL |
|
|