FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

changing form entry values before submit

 


nisibdv
I have tho following problem with a form.

I have a select element and a text element.

The text element is an optional entry for the case when an option is not
available in the select element.

The roblem I have is that if the text element is filled with some text, I want the
select element value to be equaled to the text value before submission.

The way I am trying to do that is, in the input submit button, to put an onclick event
with "document.getElementById('select_id').value=document.getElementById('text_id').value"

But this doesnt work, so in submitting the value passed on the url conserves the old value for the select element.

Any help on that will be much appreciated.
djclue917
Hmm, I don't know how to do it via plain JavaScript but here's how you do it in jQuery:

$(document).ready(function() {
$("#select_id").val($("#text_id").val());
});

If you want to try out jQuery to do a lot of amazing stuff with JavaScript in a few lines of code, then visit its website here: http://jquery.com
ashok
Hey thanks a lot for posting abt that JQuery. Never heard of it till now, but seems promising since my work involves a lot of parsing through HTML... Nice share.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.