Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line break in a form 1

Status
Not open for further replies.

xsw1971

Programmer
Jun 21, 2001
153
US
How can I force a line break in a form to NOT happen? I have a series of buttons, each its own form. I want place them vertically, but it seems that each form is creating an extra break so there is a gap between each button.

I put them in table cells to see what it was doing and that's when I noticed the extra break.

Thanks,
Jennie
 
sounds as you need to set your cellpadding or cellspacing and it could need a margin setting. or you may have even done something little like this
<input type=&quot;button&quot;> <input type=&quot;button&quot;>
see that space. well, that is intrepruted by the browser as a space hence causing a space. [smile]

as you see there can be many reasons. can you post the code in question for a little more detail. ---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
I have tried this with and without tables, so I don't think it has anything to do with margins or cellspacing. I have also tried it without the hidden fields, and by putting all code in a single line without spaces. Nothing works. I need hidden form fields because I'm passing some things that I don't want the user to see.

Code:
<form action=&quot;action1&quot; method=&quot;post&quot;>
  <input type=&quot;Hidden&quot; name=&quot;hidden1&quot; value=&quot;value1&quot;>
  <input type=&quot;Submit&quot; value=&quot;Some Value&quot;>
</form>
<form action=&quot;action2&quot; method=&quot;post&quot;>
  <input type=&quot;Hidden&quot; name=&quot;hidden2&quot; value=&quot;value2&quot;>
  <input type=&quot;Submit&quot; value=&quot;Some Value&quot;>
</form>
<form action=&quot;action3&quot; method=&quot;post&quot;>
  <input type=&quot;Hidden&quot; name=&quot;hidden3&quot; value=&quot;value3&quot;>
  <input type=&quot;Submit&quot; value=&quot;Some Value&quot;>
</form>

Theoretically this should put three buttons next to each other horizonally, but it actually stacks them vertically with an extra space in between. I would like to either display them horizontally, or vertically without the space. Maybe this is just the nature of forms?

Thanks,
Jennie
 
first, change the inputs to buttons
then name them button1 etc..
use a onClick to change the action on the name value of the button clicked.
then submit the form via the submit()
so
<form name=&quot;frm&quot; method=&quot;post&quot;>
<input type=&quot;Hidden&quot; name=&quot;hidden1&quot; value=&quot;value1&quot;>
<input type=&quot;Hidden&quot; name=&quot;hidden2&quot; value=&quot;value2&quot;>
<input type=&quot;Hidden&quot; name=&quot;hidden3&quot; value=&quot;value3&quot;>

<input type=&quot;button&quot; name=&quot;button1&quot; value=&quot;Some Value&quot; onClick=&quot;actionEquals('action1')&quot;><br>
<input type=&quot;button&quot; value=&quot;Some Value&quot; onClick=&quot;actionEquals('action2')&quot;><br>
<input type=&quot;button&quot; value=&quot;Some Value&quot; onClick=&quot;actionEquals('action3')&quot;><br>
</form>

your javascript function will look liek this
function actionEquals(objAct) {
document.frm.action == objAct
frm.submit();
}

---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
sorry, changed my mind in how to do it half way through typing and forgot to change the initial writing. what I did was pass the action url to the function
so now that I have this straight in my head [lol]
the button will look like this
<input type=&quot;button&quot; value=&quot;Some Value&quot; onClick=&quot;actionEquals('action1')&quot;><br>

then the function takes the paramter passed and concatinates the ext. to it as you see here.

<script language=&quot;javascript&quot;>
function actionEquals(str) {
str += &quot;.htm&quot;
document.frm.action == str
frm.submit();
}
</script>


you don't need to name the buttons at all. decided that was a sloppy way to do it. so the entire thing looks as this
<script language=&quot;javascript&quot;>
function actionEquals(str) {
str += &quot;.htm&quot;
document.frm.action == str
frm.submit();
}
</script>
</head>
<body>
<form name=&quot;frm&quot; method=&quot;post&quot;>
<input type=&quot;Hidden&quot; name=&quot;hidden1&quot; value=&quot;value1&quot;>
<input type=&quot;Hidden&quot; name=&quot;hidden2&quot; value=&quot;value2&quot;>
<input type=&quot;Hidden&quot; name=&quot;hidden3&quot; value=&quot;value3&quot;>

<input type=&quot;button&quot; value=&quot;Some Value&quot; onClick=&quot;actionEquals('action1')&quot;><br>
<input type=&quot;button&quot; value=&quot;Some Value&quot; onClick=&quot;actionEquals('action2')&quot;><br>
<input type=&quot;button&quot; value=&quot;Some Value&quot; onClick=&quot;actionEquals('action3')&quot;><br>
</form>

---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
CSS 'margins' can help you !!!

I didn't test it in Netscape, but it works in IE:

<html>
<head>
<title>Form Example</title>
<style>
.formstyle{
margin-top:0px;
margin-bottom:0px;
}
</style>
</head>
<body>
<form class=&quot;formstyle&quot; action=&quot;action1&quot; method=&quot;post&quot;>
<input type=&quot;Hidden&quot; name=&quot;hidden1&quot; value=&quot;value1&quot;>
<input type=&quot;Submit&quot; value=&quot;Some Value1&quot;>
</form>
<form class=&quot;formstyle&quot; action=&quot;action2&quot; method=&quot;post&quot;>
<input type=&quot;Hidden&quot; name=&quot;hidden2&quot; value=&quot;value2&quot;>
<input type=&quot;Submit&quot; value=&quot;Some Value2&quot;>
</form>
<form class=&quot;formstyle&quot; action=&quot;action3&quot; method=&quot;post&quot;>
<input type=&quot;Hidden&quot; name=&quot;hidden3&quot; value=&quot;value3&quot;>
<input type=&quot;Submit&quot; value=&quot;Some Value3&quot;>
</form>
<body>
<html>

Hope this helps,
Erik <-- My sport: Boomerang throwing !!
!! Many Happy Returns !! -->
 
I appreciate you both taking time to answer my question. I decided to go with Erik's suggestion because I hardly had to code anything extra, we are only working in IE, and it works GREAT!!

THANK YOU!
Jennie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top