HTML Tutorial


 /help/HTML Help Forum   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
javascript function and forms problem
Post new topic   Reply to topic    HTML Help Forum -> Javascript
View previous topic :: View next topic  
Author Message
itunes66



Joined: 09 Mar 2005
Posts: 184

PostPosted: Mon Apr 11, 2005 10:57 am     javascript function and forms problem Reply with quote

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

PostPosted: Mon Apr 11, 2005 1:40 pm     Reply with quote

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

PostPosted: Mon Apr 11, 2005 1:45 pm     Reply with quote

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

PostPosted: Mon Apr 11, 2005 1:51 pm     Reply with quote

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

PostPosted: Mon Apr 11, 2005 2:00 pm     Reply with quote

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

PostPosted: Mon Apr 11, 2005 2:23 pm     Reply with quote

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

PostPosted: Mon Apr 11, 2005 2:30 pm     Reply with quote

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

PostPosted: Mon Apr 11, 2005 2:52 pm     Reply with quote

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

PostPosted: Mon Apr 11, 2005 2:59 pm     Reply with quote

why i need a button thingy to change
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

PostPosted: Mon Apr 11, 2005 6:56 pm     Reply with quote

itunes66 wrote:
why i need a button thingy to change

I have no idea what you mean
itunes66



Joined: 09 Mar 2005
Posts: 184

PostPosted: Tue Apr 12, 2005 4:15 am     Reply with quote

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

PostPosted: Tue Apr 12, 2005 6:48 am     Reply with quote

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

PostPosted: Tue Apr 12, 2005 9:50 am     Reply with quote

it works
i love you LOL
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum -> Javascript All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial