HTML Tutorial


 Forum HomeForum Home   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!
2 form/submit on same line.
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Form
View previous topic :: View next topic  
Author Message
James-Nsx



Joined: 07 Mar 2008
Posts: 8

PostPosted: Fri Mar 07, 2008 5:25 pm     2 form/submit on same line. Reply with quote

I'm trying to have it so they'll display on the same line. If possible maybe have it so it only has one input and then 2 buttons, and depending on what button you click it will search the right one?

Code:
<form method="get" action="http://hiscore.runescape.com/hiscorepersonal.ws?user1=" target="_blank">
<input name="user1" size="12" maxlength="12" value="" style="font-size: 10px;" type="text">
<input value="Hiscores" style="font-size: 10px;" type="submit"></form

<form method="get" action="http://www.google.com/search" target="_blank">
<input type="text" name="q" id="q" size="20" maxlength="255" value="" style="font-size:10px" />
<input type="submit" name="btnG" id="btnG" value="Google" style="font-size:10px" />
</form>
ogsolution



Joined: 26 Dec 2007
Posts: 144

PostPosted: Fri Mar 07, 2008 11:03 pm     Reply with quote

You'll need some Javascript to help you with this:

Code:

<html>
<head>
   <title></title>
   <script type="text/javascript">
      function action( inStr ){
         var a = "http://hiscore.runescape.com/hiscorepersonal.ws?user1=";
         var b = "http://www.google.com/search?q=";
         var c = document.sform;
         if( inStr == "h" ){
            c.action = a;
         }else if( inStr == "g" ){
            c.action = b;
         }else{
            alert("I don't know where you want to go!!!");
         }
         c.submit();
         return true;
      }
   </script>
</head>
<body>
<form method="get" action="#" target="_blank" name="sform">
<input name="user1" size="12" maxlength="12" value="" style="font-size: 10px;" type="text">
</form>
<br>
<input type="button" name="btnH" value="Hiscores" style="font-size: 10px;" onclick="action('h');">
<input type="button" name="btnG" value="Google" style="font-size:10px"  onclick="action('g');">
</body>
</html>
James-Nsx



Joined: 07 Mar 2008
Posts: 8

PostPosted: Sat Mar 08, 2008 6:58 am     Reply with quote

Tyvm for the help! sadly it doesn't work. it works when i click on the hiscores button, but not the google.
ogsolution



Joined: 26 Dec 2007
Posts: 144

PostPosted: Sun Mar 09, 2008 1:17 am     Reply with quote

Sorry, revised version...

Code:
<html>
<head>
   <title></title>
   <script type="text/javascript">
      function action( inStr ){
         var a = "http://hiscore.runescape.com/hiscorepersonal.ws";
         var b = "http://www.google.com/search";
         var c = document.sform;
         if( inStr == "h" ){
            c.action = a;
            document.getElementById('str').name = 'user1';
         }else if( inStr == "g" ){
            c.action = b;
            document.getElementById('str').name = 'q';
         }else{
            alert("I don't know where you want to go!!!");
         }
         c.submit();
         return true;
      }
   </script>
</head>
<body>
<form method="get" action="#" target="_blank" name="sform">
<input name="user1" id="str" size="12" maxlength="12" value="" style="font-size: 10px;" type="text">
</form>
<br>
<input type="button" name="btnH" value="Hiscores" style="font-size: 10px;" onclick="action('h');">
<input type="button" name="btnG" value="Google" style="font-size:10px"  onclick="action('g');">
</body>
</html>
James-Nsx



Joined: 07 Mar 2008
Posts: 8

PostPosted: Sun Mar 09, 2008 10:09 am     Reply with quote

Thanks, it works perfectly like I wanted it to. Smile
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Form 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 

 
HOSTING / DESIGN
MAKE MONEY

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