473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Post via hidden input types & javascript won't work...

Hi,

I don't see why this won't work,
it are 3 links, the last one (a get) does work, but the first 2 won't.
i would like to use a post, through hidden input types
any idea?
thanks for your help!
bjorn

<HTML>
<HEAD>
<TITLE>testing...</TITLE>
<script language="Javascript">

function fAction(MachineID5, ImageFile5)
{
theForm.MachineID.value = MachineID5;
theForm.ImageFile.value = ImageFile5;
theForm.submit());
}
</script>
</HEAD>
<BODY bgcolor="#98D0F8">
<form action="bbb.php" name="theForm" id="theForm" method="post"
TARGET="right">
<input type="hidden" id="MachineID" name="MachineID">
<input type="hidden" id="ImageFile" name="ImageFile">

<A href="javascript:fAction('1','AAA.jpg');">Link to AAA</A><br>

<A href="#" onClick="javascript:fAction(6,'image/BBB.jpg');">Link to
BBB</A><br>

<A href="bbb.php?MachineID=13&ImageFile='image.jpg'" TARGET="right">Link
test</A><br>

</form>

</BODY>
</HTML>
Jan 13 '06 #1
6 4164
b. hotting wrote:
I don't see why this won't work,
it are 3 links, the last one (a get) does work, but the first 2 won't.
i would like to use a post, through hidden input types
any idea?

[...]
<script language="Javascript">
function fAction(MachineID5, ImageFile5)
{
theForm.MachineID.value = MachineID5;
theForm.ImageFile.value = ImageFile5;
theForm.submit());
}
</script>
[...]


theForm.submit());

should be

theForm.submit();

(syntax error, two brackets)

Hope this helps,

--
Bart

Jan 13 '06 #2
still doesn't work ;-((

hoped that would do it but it seems its not the only error ;-)

"Bart Van der Donck" <ba**@nijlen.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
b. hotting wrote:
I don't see why this won't work,
it are 3 links, the last one (a get) does work, but the first 2 won't.
i would like to use a post, through hidden input types
any idea?

[...]
<script language="Javascript">
function fAction(MachineID5, ImageFile5)
{
theForm.MachineID.value = MachineID5;
theForm.ImageFile.value = ImageFile5;
theForm.submit());
}
</script>
[...]


theForm.submit());

should be

theForm.submit();

(syntax error, two brackets)

Hope this helps,

--
Bart

Jan 13 '06 #3

b. hotting wrote:
<script language="Javascript">
The language attribute is deprecated use the type attribute instead:

<script type = "text/javascript">
theForm.MachineID.value = MachineID5;
theForm.ImageFile.value = ImageFile5;
Just a matter of personal preference, I like to use the square bracket
notation:

document.forms["theForm"].elements["MachineID"].value = MachineID5;
document.forms["theForm"].elements["ImageFile"].value = ImageFile5;
theForm.submit());
You have an extra closing parenthesis. You could also try:

document.form["theForm"].submit();

<A href="javascript:fAction('1','AAA.jpg');">Link to AAA</A>
The use of pseudo javascript protocol is highly frowned upon. Try at
least using the onclick event handler:

<a href = "#" onclick = "fAction('1', 'AAA.jpg');">Link to AAA</a>
<A href="#" onClick="javascript:fAction(6,'image/BBB.jpg');">Link to BBB</A>
The pseudo javascript protocol has no place in the event handler,
remove it:

<a href = "#" onclick = "fAction(6, 'image/BBB.jpg');">Link to BBB</a>

In the above two links, you'll most likely want to return false so that
link won't get followed. You should also note, for a graceful
degradation, you should provide an actual link, in case the user has
javascript disabled.
<A href="bbb.php?MachineID=13&ImageFile='image.jpg'" TARGET="right">Link
test</A><br>


It seems to me that this link doesn't even need to be within the form,
since you're not submitting the form with this anyway.

Jan 13 '06 #4
web.dev wrote:
b. hotting wrote:
theForm.MachineID.value = MachineID5;
theForm.ImageFile.value = ImageFile5;


Just a matter of personal preference, I like to use the square bracket
notation:

document.forms["theForm"].elements["MachineID"].value = MachineID5;
document.forms["theForm"].elements["ImageFile"].value = ImageFile5;


It is not only a matter of personal preference. The latter (yours) is
the standards compliant approach, the former is the proprietary one.
theForm.submit());


You have an extra closing parenthesis. You could also try:

document.form["theForm"].submit();


document.form_s_, as above.
PointedEars
Jan 13 '06 #5
Ran into the same problem a while back, tried a few combinations and
finally got it to work on IE and firefox. Check out:

http://www.suckingfish.com/view.do?crumb_id=dsid_1104

Good luck,

Matt

Jan 13 '06 #6
Thanks guys!
Really appreciated!

Jan 14 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rui Pestana | last post by:
Hello all, I want to use the POST method to submit the form and then grab the parameters in the asp file with request.form("parm"). The problem is that I am using the _search target to open...
4
by: Dodo | last post by:
Is it possible to create a link that can post a value to an ASP page without java?
2
by: cschang | last post by:
I have a page created by using response.write. I just found out that if I put a <input type=hidden..> within a <div> section, this <input ..> could not be referenced in the javascript. Becasue...
18
by: q2005 | last post by:
Hi, all When I do as the following, it becomes a GET action to the the server. How do I make it as a POST action? That means I don't want the string after "?" show on URL bar and, to the...
3
by: kaushalmbhavsar | last post by:
I am working on one VB.NET application where I am using WinHttp.dll to post request on website. First request is for Login Page and I have gone through all input types of that page and pass those...
24
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button...
4
by: WB | last post by:
Hi, I need to validate a hidden input in my webform to ensure that it's got value. The controls look something like this: <input id="HidSelectedStates" type="hidden" runat="server" /><br...
23
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
1
by: Sideswipe | last post by:
I am trying to concatenate selected values from numerous radio button sets into 1 series and assign it to a single hidden field. I have never done javascript before and I continue to run into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.