/    Sign up×
Community /Pin to ProfileBookmark

setting value of hidden field

I have a series of buttons that are attached to a JavaScript. When button is pressed condition statements are executed and form is submitted. In form I have a hidden field ‘actionType’ that needs to be set to a value of the button when form is submitted. The problem is that value of ‘actionType’ is never set. What’s the problem?

[code=php]
button:
<input type=”image”
id=”search”
src=”include/searchBlue89x33.gif”
name=”search”
class=”btn”
onmouseover=”this.className=’btn-on’;”
onmouseout=”this.className=’btn’;”
onClick=”actionListener()”>
[/code]

[code=php]
JavaScript:
function actionListener(){
var command = window.event.srcElement.id;
var isSubmitOK = true;
if(command == ‘search’){
showWait();
document.body.style.cursor = “wait”;
document.gesForm.add.disabled = true;
document.gesForm.search.disabled = true;
document.gesForm.clear.disabled = true;
document.gesForm.cancel.disabled = true;
}
if(isSubmitOK){
document.getElementByName(‘actionType’).value = command;
document.getElementById(‘ges’).submit();
}
}
[/code]

[code=php]
JSP page:
<input type=’text’ class=’input’ id=’coln’ name=’coln’ size=’30’ value=” onFocus=”this.select()” maxlength=’30’>

<input type=”hidden” name=”tableName” value=”color_1″>
<input type=”hidden” name=”actionType” value=””>
<input type=”hidden” name=”dataSize” value=”0″>
<input type=”hidden” name=”buttonLayout” value=”include/buttons/default”>
[/code]

thanks for your help!
camokat

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@camokatauthorJun 08.2004 — Ok, found the problem. I was setting button to disabled=true:
[code=php]
document.gesForm.add.disabled = true;

document.gesForm.search.disabled = true;

document.gesForm.clear.disabled = true;

document.gesForm.cancel.disabled = true;

[/code]


Since my buttons are images, disabled does not work, so it was causing error.

However, the reason I was disabling buttons was becasuse I wanted to prevent users from hiting search button while request was processed by the server. The reason being, is if they get impatient with waiting they can hit the button again and again thus overloading server with same requests and potentially putting it down. Any suggestions on workaround?

thanks,

camokat
×

Success!

Help @camokat 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.13,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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