hi

my interface has spry tabbed panels each in its own form, my problem is whenever i submit data on any of the panels in a form, my page reloads with focus on the first panel(index 0). I've tried a number of javascript methods on the form onSubmit but it hasent worked.
How can i maintain focus on the panel from which i submitted data?

Thanks

Recommended Answers

All 7 Replies

Some code would be useful as I cannot see what needs to be changed. But if you are talking about iframes then you could use target='framename'

<div class="TabbedPanelsContent style10">
	<form name="addstudents" method="post" onSubmit="return validate(this); " enctype="multipart/form-data">
	<fieldset><legend><span class="style6 style8"><strong>ADD STUDENTS</strong></span><span class="style8">
    </span></legend>
<span class="style8"><table width="439" align="" cellpadding="4" cellspacing="0" bgcolor="#EDEDED">	
		<tr class="tblSubHead">
			<td width="308">Upload the .csv excel file of Students to be added  to the database</td>
		</tr>
		<tr class="txt">
			<td valign="top" bgcolor="#FFFFFF"><div id="dvFile">
			  <input name="item_file[]" type="file" id ="item_file[]" size="55" >
			</div></td> 
		  </tr>
		<tr>
			 <td align="center"><input type="submit" value="Upload File" name="Students">
			<input type="reset" name="Submits" value="Remove Files" />
			
		
		    <a href="downloadingprojects.php"></a></td>
		</tr>
	</table>
      </p>
</span><br />
<br />
<br />
</p>
</fieldset>
</form>

If you meen the window refreshes and is blank for like a second then you will need to change the way it submits. To do that, make the processor a seperate php file which has no html output except one javascript code. Then make that processor appear in a new window and when it is processed it will then close the new window automatically.

So in your form opening tag, change the <form tage to the following:

<form name="addstudents" method="post" onSubmit="return validate(this); " enctype="multipart/form-data" target='_new' action='processor.php'>

Then in processor.php, that is where the $_POST array will appear and where the form will be submitted. So at the bottom of processor.php place the following javascript:

<script>
window.opener='x';
window.close();
</script>

hi

thanx but what i meant was there are several panels with similar code to the one i gave earlier but if I submit information on the 2nd, 3rd or 4th panel, instead of remaining on that panel it goes to the 1st panel.

hi

thanx but what i meant was there are several panels with similar code to the one i gave earlier but if I submit information on the 2nd, 3rd or 4th panel, instead of remaining on that panel it goes to the 1st panel.

Hi I didnt get exactly ur problem..

try to do this...

get ur present url,

$url=$_SERVER['HTTP_REFERER'];

when u reloading the page then u need to give the link to $url;

...

$url=$_SERVER['HTTP_REFERER'];

when u reloading the page then u need to give the link to $url;

That will not work all the time since not all browsers send the referer information. That is why it is best to first check if the referer array is empty, if it is empty then use javascript else use the php referer.

to fix a problem like this I would turn to ajax. it will submit the form to php using javascript without reloading the page. it can get a little complicated, but once you get a basic understanding of it you should find it helpful.

also, you could try putting a default tab variable in the javascript. then have a hidden element in your form with the id or index of the tab and submit it to php. then php can use that to echo the index/id of the panel in the javascript so it loads the correct one.

ex.

var default = <?php echo $id; ?>;

where $id is the value of the hidden element.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.