/    Sign up×
Community /Pin to ProfileBookmark

form submit problem

I have a page that builds a list of users. I’ve added a checkbox next to user name and would like to submit user IDs when I click on the next page in results paging. Here’s how it looks when I look at page source:

[code=php]
<form name=”SelectForm” method=”post”>
<table>
<tr>
<td><input name=”SelectedID[1984]” value=”1984″ type=”checkbox”></td>
<td>User name</td>
</tr>
<tr>
<td><input name=”SelectedID[457]” value=”457″ type=”checkbox”></td>
<td>User name</td>
</tr>
<tr>
<td><input name=”SelectedID[3]” value=”3″ type=”checkbox”></td>
<td>User name</td>
</tr>

<tr>
<td colspan=2>
<div style=”float: left;”>
<input name=”go2email” value=”send a message to selected” type=”submit”>
</div>
<div style=”float: right;”>
<b>1</b></font> |
<a href=”./?slate=AVBAFlo3A” class=”a-nl” onclick=”javascript:document.SelectForm.submit();”>2</a> |
<a href=”./?slate=AVBAFlg3A” class=”a-nl” onclick=”javascript:document.SelectForm.submit();”>3</a>
</div>
</td>
</tr>
</table>
</form>
[/code]

It works when I use the button, but not when I use paging links. Is there anything I miss here?

What I’m trying to do here is to display the list of users. When checkboxes are selected and if the button (go2emai) is submitted an new screen is displayed that will allow fo message composition form and then sent to the array of users selected. If the list of results is long, I’ll have paging script that will go to the next page of results but I’d like to be able to keep results of selected users on one page when advanced to the next page and keep adding them to a list before the button is clicked.

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@FourCourtJesterOct 03.2008 — Hi there,

I don't know about 'paging' functionality, but I do know you can't submit a form more than once.
Copy linkTweet thisAlerts:
@santaauthorOct 03.2008 — I am not trying to submit it more then once. When I click paging link it submits the results and I store it in an array. The issue I have is that I can't seem to be able to submit it using onclick="javascript:document.SelectForm.submit();"
Copy linkTweet thisAlerts:
@santaauthorOct 03.2008 — OK, I've added the script:
[code=php]
<script language="JavaScript"><!--
function SelectSubmit() {
document.SelectForm.submit();
alert ('test');
}
//--></script>
[/code]

and changed the links to:
[code=php]
onclick="SelectSubmit()"
[/code]


However, it only works while I have alert in the script. If I take it out, it stopes submitting selected values. That is so weird...
Copy linkTweet thisAlerts:
@santaauthorOct 03.2008 — OK, it's even worse then I thought. When I test in FireFox, with alert, I get alert when I click the link and see submitted values. If IE, I get alert but no values are submitted... I am LOST... ANY BULLET-PROOF SOLUTIONS AVAILABLE OUT THERE?
Copy linkTweet thisAlerts:
@FourCourtJesterOct 03.2008 — w3schools has a simple example that may help you out:

<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
function changeAction()
{
var x=document.getElementById("myForm");
alert("Original action: " + x.action);
x.action="default.asp";
alert("New action: " + x.action);
x.submit();
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;form id="myForm" action="js_examples.asp"&gt;
Name: &lt;input type="text" value="Mickey Mouse" /&gt;
&lt;input type="button" onclick="changeAction()"
value="Change action attribute and submit form" /&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@santaauthorOct 03.2008 — Noup... same thing. With alert enabled posts in FF but not IE.

I think it has to do that when i use button, I do not change the page, when I click link it changed action (i.e. URL)

I think I need to look into AJAX and store values into array on the background when I check the checkbox, so when i go to the next page they are already stored.

Any simple script that will allow me to accomplish this?
Copy linkTweet thisAlerts:
@FourCourtJesterOct 03.2008 — can you publish the page for study?
Copy linkTweet thisAlerts:
@NedalsOct 04.2008 — When you click an anchor link:

<a href="./?slate=AVBAFlo3A" class="a-nl" onclick="SelectSubmit()">2</a>

the page, not the form, will perform a 'get' submit

You need the following..

<a href="./?slate=AVBAFlo3A" class="a-nl" onclick="return SelectSubmit()">2</a>

and add a 'return false' at the end of your function.

This will now submit the form when you click the link, BUT it will NOT submit that query string. './?slate=AVBAFlo3A'

You will need to add a hidden field to tell the server which page you are on and the SelectSubmit() function needs to

set the value depending on the up/dn data.

<a href="#" class="a-nl" onclick="return SelectSubmit('up')">Up</a>

<a href="#" class="a-nl" onclick="return SelectSubmit('dn')">Dn</a>
×

Success!

Help @santa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...