Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

form input value changer

Javascript coding ..

Moderators: macek, egami, gesf

form input value changer

Postby epox123 » Tue Aug 30, 2005 7:04 pm

Hi everyone im not that good at java script so i dont know how to right what i want to do.

Code: Select all
<script language="JavaScript" type="text/JavaScript">
<!--
function subfom(fms, fis, xelektid){
/*var fms;
var fis;
var xelektid;*/
alert(fms);
alert(fis);
alert(xelektid);
document.fms.fis.value = xelektid;
if(document.fms.fis.value == xelektid){
document.fms.submit();
}
}
//-->
</script>
<a href="#" onClick="javascript: subfom('bottom', 'order_by', 'itemArtists');">Artists</a>


can this be done or do i have to just make tons of this same script but with the difrent forms and text fields :(? or is this right but becouse im useing hidden input it cant see it :(.
User avatar
epox123
New php-forum User
New php-forum User
 
Posts: 77
Joined: Mon Aug 08, 2005 8:44 pm
Location: USA

Please check this script

Postby s_narkar » Wed Aug 31, 2005 2:57 am

Hi,
If my Understanding is correct regarding your mail, then this script may help you. Please check it.


<style>
body{font-family:verdana,arial;font-size:11px}
</style><body>
<script language="JavaScript" type="text/JavaScript">
function subfom(field_name, field_value){

/*alert(field_name);
alert(field_value);*/

alert ("The Form will get submited at FIELDNAME = "+field_name+" and FIELDVALUE = "+field_value);
document.test.action = "page_name.php?fieldName="+field_name+"&fieldValue="+field_value;
document.test.submit;
}
</script>
<form name="test" method="post">
<b>NOTE : </b>You have to replace the (page_name.php) in the javascript with the name of the page you want to submit the form.
<br>Also the (fieldName and fieldValue) in javascript with the variable you are using in the php page.
<br><br>
<a href="#" onClick="javascript: subfom('order_by', 'itemArtists');">Artists</a>
<br><br>
<a href="#" onClick="javascript: subfom('order_by', 'itemSongs');">Songs</a>
<br><br>
<a href="#" onClick="javascript: subfom('order_by', 'itemAlbums');">Albums</a>
<br><br>
<a href="#" onClick="javascript: subfom('order_by', 'itemTracks');">Tracks</a>
</form>
</body>


Regards,
http://www.executz.com
(Visit the site for more details)
User avatar
s_narkar
New php-forum User
New php-forum User
 
Posts: 20
Joined: Tue Nov 02, 2004 11:29 pm

Postby epox123 » Wed Aug 31, 2005 7:46 am

Hi thanks :) for your help. the only question i have is i have tons of forms and they will all need this same jscript so is there any way to send the form var with out it giving me an error?

<a href="#" onClick="javascript: subfom('forum_0', 'order_by', 'itemArtists');">Artists</a>
User avatar
epox123
New php-forum User
New php-forum User
 
Posts: 77
Joined: Mon Aug 08, 2005 8:44 pm
Location: USA

Postby epox123 » Wed Aug 31, 2005 8:58 am

well i starting messing around and decided to go with a switch ;/

Code: Select all
<script language="JavaScript" type="text/JavaScript">
function subfom(doNum, xelektid){
var xelektid;
var doNum;
switch (doNum) {
case '1':
window.document.form1.order_by.value = xelektid;
if(window.document.form1.order_by.value == xelektid){
window.document.form1.submit();
}
break
case '2': //second form
window.document.form2.order_by.value = xelektid;
if(window.document.form2.order_by.value == xelektid){
window.document.form2.submit();
}
break
default:
}
}
</script>


<a href="#" onClick="javascript: subfom('1', 'itemArtists');">Artists</a>

this is prety optimized but if you got alot of forms ... lol lot of cases you have to add ;/

anyways thanks for your help :)
User avatar
epox123
New php-forum User
New php-forum User
 
Posts: 77
Joined: Mon Aug 08, 2005 8:44 pm
Location: USA


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron