[Seaside] JavaScript anyone?

Julian Fitzell julian at beta4.com
Mon Mar 31 12:36:11 CEST 2003



Nevin Pratt wrote:
> 
> 
> Ned Konz wrote:
> 
>> On Friday 28 March 2003 10:02 am, Nevin Pratt wrote:
>>  
>>
>>> I would like to have a page with "Next Image" and "Previous Image"
>>> buttons that when pressed, shows another photo.  However, I don't
>>> want the entire page to need to get refreshed.  I would like *just*
>>> the image to change-- nothing more.
>>>
>>> The only way I know of to do that is via JavaScript.
>>>   
>>
>>
>> Can't you make it so that it'll work as desired in JavaScript, but 
>> also degrade gracefully to refreshing the entire page when someone has 
>> JS disabled?
>>
>>  
>>
> I don't know.  I've got it working right now without JavaScript.  One 
> sample run produced the following html fragment:
> 
>   <form method="POST" 
> action="/seaside/index/@8ead21b8-2f44-44ae-99d8-8685af0227f5/23522" >
>   <input value="<- Previous Image" name="1" type="submit" >
>   <input value="Next Image ->" name="2" type="submit" >
>   <input value="Random Image" name="3" type="submit" >
>   </form>
> 
> 
> So, I suppose the solution would look like this (notice the addition of 
> the 'onClick' property to the buttons):
> 
>   <form method="POST" 
> action="/seaside/index/@8ead21b8-2f44-44ae-99d8-8685af0227f5/23522" >
>   <input value="<- Previous Image" name="1" type="submit" 
> onClick="previmg()">
>   <input value="Next Image ->" name="2" type="submit" onClick="nextimg()">
>   <input value="Random Image" name="3" type="submit" onClick="pickrand()">
>   </form>
> 
> 
> And then, of course, include the JavaScript found here so we have a 
> definition of previmg(), nextimg(), and pickrand():
> 
>   http://www.jsmadeeasy.com/javascripts/Images/Image%20Gallery/list.htm
> 
> With this, though, I'm really not sure what would actually happen when 
> the buttons are clicked.  For a JavaScript-enabled browser, would they 
> both submit the form, as well as run the JavaScript function?  Or would 
> it just run the function?  If JavaScript was not enabled, what would 
> happen?  Would it still submit the form in this case?

You should be able to return false from your javascript onclick handler 
to indicate that you do not want the normal action (ie. submitting the 
form) to take place...  been a while since I've done any JS, but that's 
what I remember working.

<snip>

Julian



More information about the Seaside mailing list