Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2007, 06:23 PM
PayBas PayBas is offline
 
Join Date: Jun 2006
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Replacing multiple buttons with images in the same form?

Okay here's the deal, I'm trying to replace the "preview post" and "submit new thread" buttons in the "newthread" template with images, I need this for my skin.

So very basically this is what vBull looks like at default:

Code:
<form action="newthread.php?do=postthread&amp;f=$forumid" method="post" name="vbform"<if condition="!is_browser('webtv')"> onsubmit="return vB_Editor['$editorid'].prepare_submit(this.subject.value, $vboptions[postminchars])"</if>>

<lots of hidden inputs>

<input type="submit" class="button" name="sbutton" value="$vbphrase[submit_new_thread]" accesskey="s" tabindex="1" />
<input type="submit" class="button" name="preview" value="$vbphrase[preview_post]" accesskey="r" tabindex="1" />
</form>
and I want it to look something like this:

Code:
<form action="newthread.php?do=postthread&amp;f=$forumid" method="post" name="vbform"<if condition="!is_browser('webtv')"> onsubmit="return vB_Editor['$editorid'].prepare_submit(this.subject.value, $vboptions[postminchars])"</if>>

<lots of hidden inputs>

<input type="image" class="button" name="sbutton" src="images/post.gif" id="{$editorid}_save" value="$vbphrase[submit_new_thread]" accesskey="s" tabindex="1" />
<input type="image" class="button" name="preview" src="images/preview.gif" value="$vbphrase[preview_post]" accesskey="r" tabindex="1" />
</form>
However this does NOT work because Internet Explorer discards the "value" statement or something (it does work in FF). Basically you cannot have multiple image submit buttons cuz then it messes up .

I know this can be fixed by using javascript, but I cannot get it working.

Any help would be appreciated.
Reply With Quote
  #2  
Old 01-11-2007, 10:24 PM
Floris Floris is offline
 
Join Date: Jan 2002
Posts: 1,898
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Because IE is like Deathstar, bad for all people.

http://groups.google.com/groups?th=e...1b1eda2&rnum=1

There is a technicality related to form submission if you use an image submit button. It is usually relevant only if you have several such buttons in one form. That's perfectly valid per se, but the usual instructions for including several submit buttons do not apply as such. When using image submit buttons, you need to use specifically different NAME attributes in order to be able to recognize in the form handler which button was clicked on.

The reason to this is the way in which image submit buttons contribute to form data set: the value of the VALUE attribute is ignored, and the coordinates of the clicked location are passed instead. For example, if you have <input type="image" src="submit.gif" name="foo" value="bar">, then the form data set contains the fields foo.x and foo.y, with numeric values that indicate the x and y coordinates of the clicked location.

http://www.cs.tut.fi/~jkorpela/forms/imagebutton.html
Reply With Quote
  #3  
Old 01-11-2007, 10:35 PM
PayBas PayBas is offline
 
Join Date: Jun 2006
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah I read those sources even before I posted this topic . But this line puzzels me:

Quote:
In addition to the usual limitations imposed by using client-side scripting, these techniques have some specific problems. In particular, the ONSUBMIT event handler for the form is not invoked; this however is not very serious, since you can put the code (e.g. for form data checking) into the ONSUBMIT attribute value before calling submit(). The JavaScript Form FAQ contains answers to questions related to these issues.
Does that mean that I cannot use the described javascript method in my case by default?


My javascript skills kinda suck so I ended up with stuff like this:
Code:
<input type="image" class="button" name="preview" src="/images/en_US/preview.gif"  onclick="javascript: document.vbform.submit.value('$vbphrase[preview_post]');return false;" accesskey="r" tabindex="1" />
which didnt get me anywhere.

You see the problem for me is that the "preview' button doesnt get registered correctly (or at all). Doesn't matter if I press "post" or "preview".... it gives the same result... the message gets posted.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:10 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03760 seconds
  • Memory Usage 2,180KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete