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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange form problem with firefox

Status
Not open for further replies.
Jul 28, 2005
358
FR
Hi, I hope this is in the right place.

I am developing a site that has a form to submit details. On the form, I have a php if statement that passes different things through the form to call later funtionality. This in itself isn't a problem.

What is a problem though is how the form behaves. If I use IE as my browser everything works fine, but in firefox it refuses to link from the form to the new page. I have looked through the html that is generated by firefox (from a php script - shouldn't affect things) and can't see any reason for it. It is identical html as in IE.

Here is the code (very rough and ready I know but I am still in development).

Code:
	<form name="form1" method="post" action="booking.php">
	<input name="choiceofapp" type="hidden" value="3,7,12,13">
	<input name="people" type="hidden" value="9">
	<input name="service" type="hidden" value="2">
	<input name="completeprice" type="hidden" value="3100">
	<input name="fromdate" type="hidden" value="12/12/2006">
	<input name="todate" type="hidden" value="24/12/2006">
	
    <table width="123">
	      <tr>

        <td width="115">
		
		<label>
          <input type="radio" name="RadioGroup1" value="1">
          Book Now</label></td>
      </tr>
     
       
		
		<label>
		
          <input type="radio" name="RadioGroup1" value="2">
          Create Option</label></td>

     
	      </table>
    <input type="submit" name="Submit" value="Submit">
	</form>

As you can see, the form has the target url in it but when I look at the form info page info tool in firefox it has no name and no url to link to. Can anyone see what's wrong??

Oh, and by the way, the values are dynamically produced.

Thanks
Richard
 
This is probably not the entire code on the page, right? The only thing that springs to mind is that there is an unclosed double quote above the form tag, which confuses FF into thinking that <form name=" is still a part of that quote. In that respect it cannot see the form opening tag and cannot execute anything.
 
Maybe FF is confused by the fact that the second radio button table cell only has a </td>, and doesn't appear in a <tr>? Dunno why this should affect the form action, but getting your code valid to begin with is always a good first step in debugging.

Anyway, why use a table at all?

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Thanks guys,

Definitely not the whole page, you are right. he rest didn't seem to have anything else to do with the form anyway.

I'm not sure where you mean the unclosed double quote is.

The tables will be going, it's just a beginning of development on this page and I'll do the css afterwards.

The strange thing is when I take the form code out of the rest of the page and create a new file with just that in it works perfectly with the correct url being called. Maybe it is something to do with the table parameters. I'll strip them all out now and see if it makes a differnce.

Rich
 
Didn't change anything apart from the layout of the page. There must be something that is messing it up,

Here is the sourcecode without the table tags.

Code:
<form action="corpsin.php" method="post">
	<input name="Yes" type="submit" value="Yes">
	<input name="pidlist" type="hidden" value="37,79">
	<input name="fromdate" type="hidden" value="12/12/2006">
	<input name="todate" type="hidden" value="24/12/2006">
	<input name="service" type="hidden" value="2">
	</form>

Seems like firefox wants to play silly beggars.

Rich
 
Sorry, wrong form there,

Here is what I should have posted.

Code:
	<form name="form1" method="post" action="booking.php">
	<input name="choiceofapp" type="hidden" value="3,7,12,13">
	<input name="people" type="hidden" value="9">
	<input name="service" type="hidden" value="2">
	<input name="completeprice" type="hidden" value="3100">
	<input name="fromdate" type="hidden" value="12/12/2006">
	<input name="todate" type="hidden" value="24/12/2006">
	
    
	      
		
		<label>
          <input type="radio" name="RadioGroup1" value="1">

          Book Now</label>
     
     
       
		
		<label>
		
          <input type="radio" name="RadioGroup1" value="2">
          Create Option</label>
     
	      
    <input type="submit" name="Submit" value="Submit">
	</form>

Rich
 
richcleverley, even more reason to support my initial idea. I can at this point only assume and speculate, since you're not showing the rest of your code, but this is something that might have happened. Say that you have your form enclosed in a div. The code might look like this:
Code:
<div class="container" id="main>
 <form name="form1" method="post" action="booking.php">
 ...
Now see, id in a div does not have the closing double qoute so browser would assume that your div has an id of "main><form name=". And a bunch of other attributes, ending with a > from the form. In that case, the browser would not see the form tag and will not want to execute the thing. Certain browsers could assume the closing quote and work nevertheless (IE) while others would follow the code and crash (FF).

That is a logical assumption, though I do not claim it is correct.
 
No, at the moment there is no div there,

Here is the php concerned that creates the form so you can see how it is made up.

Code:
<p> Total price = € <? echo " " . $completeprice ;
	$priceperperson=ceil ($completeprice/$people);
	?></p>
      <p> Price per person =€ <? echo " " .  $priceperperson;?> </p>
	  <p> From:  <? echo $fromdate . " " ?> Until: <? echo $todate?>
	<form name="form1" method="post" action="booking.php">
	<input name="choiceofapp" type="hidden" value="<? echo $choiceofapp ?>">
	<input name="people" type="hidden" value="<? echo $people?>">
	<input name="service" type="hidden" value="<? echo $service ?>">
	<input name="completeprice" type="hidden" value="<? echo $completeprice ?>">
	<input name="fromdate" type="hidden" value="<? echo $fromdate ?>">
	<input name="todate" type="hidden" value="<? echo $todate ?>">    
	<?
	if ($ranking==1){
	?>  
		<label>
          <input type="radio" name="RadioGroup1" value="1">
          Book Now</label>
     <label>		
          <input type="radio" name="RadioGroup1" value="2">
          Create Option</label>    
	  <? 
	  }else{
	  ?>	  
	  <label>
          <input type="radio" name="RadioGroup1" value="2">
          Send Booking Enquiry</label>
		  	  <?
	  }
	  ?>    
    <input type="submit" name="Submit" value="Submit">
	</form>

I can't see anything open that shoudln't be (but I have been in front of the thing all day!) but maybe someone else can.

Rich
 
Ok, your php code is really confusing since you keep switching context. But that should not be the problem although I don't know how php parser is good at interpreting this: [tt]<? echo $todate?>[/tt]. Mainly, how do you think it knows when is the end of variable and start of the closing php bracket? Other than that, I see you're putting the form in a paragraph. That will not work. I don't think it should hinder the functionality of the form, but I guess it might. If I were you, I'd change to the following:
Code:
      <p> From:  <? echo $fromdate . " Until: " . $todate . "</p>"; ?>
    <form name="form1" method="post" action="booking.php">
I mean, I would change all the php switching, but this is what might be interfering with your form.
 
I guess you're right about the change of context. I tend to do this while designing functionality and then go back when I'm happy and remormat the code.

Anyway, your suggestion didn't make a blind bit of difference; thank though :)

Intersetingly, if I save the webpage and then look at the source, I notice that the form name has dissapared altogether (even though it's visible in the view page source)!!

Very odd.

Rich
 
Got it!! It seemed to be all the context swapping in the php. Once I put all the html above the form into echo statements instead of mixing html and php it worked. It was splitting the form action before so it couldn't work.

Thanks guys for all your help!

Richard
 
Oh and yes Chris, I'm using Firefox 1.0.4. Don't use beta's for development work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top