/    Sign up×
Community /Pin to ProfileBookmark

Issue with .submit()

I am attempting to create a textbox to enter some emails, then use a button to call a javascript function. Then function then checks for yyy.com in each address, and if incorrect issues an alert, if correct it does a submit(). However, once submitted, I am unable to read the POST value and name of the button, which I need. If I just create a regular submit button without the javascript, everything works fine. I can’t figure out why the value and name aren’t being sent, when the javascript shows them as being correct. This is being page is being written with REXX on z/VM, hence all the queues.

queue ‘<FORM NAME=”ECCN” ACTION=”../software/ECCNlist.wrkvmgw” METHOD=”POST”>’
queue ‘<input type=”text” name=”maillist” MAXLENGTH=200 SIZE=50>’
queue ‘<input type=”button” value=”Email List” name=”InpAction” onClick=”javascript:check_mail(this.form);”>’
queue ‘</FORM>’

function check_mail(form)
{
var maillist = form.maillist.value;
maillist.toLowerCase();
var index = 0;
var invalid_mail = ”;
var mailarray = maillist.split(” “);
while (index < mailarray.length) {
if (mailarray-index- != ” && mailarray-index-.indexOf(‘yyy.com’)
{
invalid_mail = invalid_mail+mailarray-index-+’ ‘;
}
index+=1;
}
if (invalid_mail != ”) {
alert(“Invalid email address(es):n”+ invalid_mail);
}
else {
alert(document.ECCN.action); /* This is assigned correctly */
alert(document.ECCN.method); /* This is assigned correctly */
alert(document.ECCN.InpAction.name); /* This is assigned correctly */
alert(document.ECCN.InpAction.value); /* This is assigned correctly */
document.ECCN.submit(); /* Does submit to the correct action */
}
}

Again, the javascript seems to work correctly, but when I read the POST variables in, value=”Email List” name=”InpAction” are no where to be found.

This is how they are read in using REXX:

‘CGI READ 1 (TRANSLATE USENGLISH VAR ARGSTRING’
‘CGI URLDECODE (VAR ARGSTRING INTO PARMS.’

InpAction = strip(parms.InpAction) /* InpAction should = “Email List” , but is not assigned to anything */

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@MongusSep 21.2005 — Data from input buttons isn't sent when a form is posted. Submit buttons do send data.

Something like this should work for you:
queue '&lt;FORM NAME="ECCN" ACTION="../software/ECCNlist.wrkvmgw" METHOD="POST" [b]onSubmit="return check_mail(this)"[/b]&gt;'
queue '&lt;input type="text" name="maillist" MAXLENGTH=200 SIZE=50&gt;'
queue '&lt;input type="[b]submit[/b]" value="Email List" name="InpAction"&gt;'
queue '&lt;/FORM&gt;'
Then change your check_mail to return false if it fails validation or true to submit the form instead of submitting the form from check_mail.
Copy linkTweet thisAlerts:
@FangSep 21.2005 — As [B]Mongus[/B] wrote, it is not a [URL=http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.2.1]control[/URL]
Copy linkTweet thisAlerts:
@Mrk200authorSep 21.2005 — That worked. Thanks a lot guys. I should have posted a while ago, could have saved myself a few hours. ?
×

Success!

Help @Mrk200 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...