help with Image submit button

Rev22only
Rev22only used Ask the Experts™
on
Hello I have the following code in one of my php programs..
<input type="submit" id="someid" value="' . JText::_( 'Submit' ) . '" />

I want the above to be replaced by image submit button by
<a href="javascript:document.adminForm_1.submit();" ><img src="submit.jpg" border="0"></a>

But for some reason the form submission does not work in my script after the later code is used..

any help??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Change the input type to image and provide the image in the attribute src.  E.g.

<input type="image" src="submit.jpg" alt="" />

bol

Commented:
By the way ... you should not have javascript in the href attribute but use an event (e.g. onclick) in the tag instead.  The method I recommended above is better but if you need javascript in an anchor tag you should have it like ...

<a href="#" onclick="myJavascript();">My Link</a>

bol

Author

Commented:
I tried both but for some reason my Ajax form does not work..
FYI the above code is part of a CMS, it is not a single script..

This is the original line <input type="submit" id="someid" value="' . JText::_( 'Submit' ) . '" />
I want an image to be used for submit button..
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Commented:
We probably need more info then.  If this is part of other code and may be changed or affected by it then that would explain why it isn't working.  Without a better idea of that code and details of any script error messages I can't say for sure how to fix it (if you can).

You can test what I suggested in a normal html page (just to see how it works) if you'd like.  At the least that will show how the html should be but working/modifying CMS can sometimes be tricky.

bol

Author

Commented:
yeah.. I just thought the same.. I tried to track the code but its stretching everywhere..

Just thinking how these two submit form differently..
<input type="submit" id="someid" value="' . JText::_( 'Submit' ) . '" />
<a href="#" onclick="myJavascript();">My Link</a>
Commented:
If the original was like the first tag your problem may just be not providing the name/value pair that is needed.  You could remedy this by adding ...

<input type="hidden" id="someid" value="' . JText::_('Submit') . '" />

and then using the input image tag I provided.  If you want you can try just adding the id and value pair above to the image input I provided but I am not sure if that will work (i.e. the browsers will see that info in an image input button).

bol

Author

Commented:
Thanks for that..

I added
<input type="hidden" id="aiContactSafeSendButton" value="' . JText::_('Submit') . '" />'
and below
<a href="#" onclick="document.adminForm_1.submit();" id="aiContactSafeSendButton" ><img src="images/submit.jpg" border="0"></a>

Now the form is getting submitted when image button is clicked but Ajax is not working..the result of the form is opening in a new page...

Any inputs?

Commented:
I have been offline (or at least not able to come back to EE) for a few days.  Sorry for the slow response.

I am glad that fixed the problem here.  I am not sure about the AJAX part.  We don't really have details on it and so I don't even have anything general to point at.  I would need a better idea of how AJAX relates to the page and form.

It seems that may be getting to a different question if I am right.  If so and you would like expert help with it then it would be best to open a new question for it (with a more accurate title and the details).

Let me know if you have a question about this or if you feel I have misread the relationship of AJAX to what we did here.

bol

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial