coldkill Posted August 30, 2006 Share Posted August 30, 2006 Hey folks,I have a slight problem with one of my JS scripts. It doesn't work for one ¬¬.It is supposed to change the action value of a form and is called from the onClick HTML function. Here is a the script:[code]function Action(){ var form = document.getElementById(\'editform\'); var checkbox = document.getElementById(\'preview\'); if( checkbox.checked == true ) { form.action = "'.DOMAIN.'index.php?module=admin&id=news_mod&preview" } else { form.action = "'.DOMAIN.'source/action/exec.php" }}[/code]It's echoed from a PHP script and DOMAIN is changed for the current working directory of the site. Thanks in advance,Mike Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 31, 2006 Share Posted August 31, 2006 for the a = bool ? true_val : false_valall I see is a = val ? true_val : false_val... don't you need to test that first val against something before something is returned? Quote Link to comment Share on other sites More sharing options...
coldkill Posted August 31, 2006 Author Share Posted August 31, 2006 When it is called it is alternated I belive. Although I will try an if statement instead of the above. ::EDIT::Updated the code above. Still doesn't work. Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 31, 2006 Share Posted August 31, 2006 is it possible to see your form code as well? thanks.Now does the JS script not work because there is something wrong syntactically?Or does the function get called but it just doesn't do what you expect it to do?Make sense? Quote Link to comment Share on other sites More sharing options...
coldkill Posted August 31, 2006 Author Share Posted August 31, 2006 Yeah, it is called but it doesn't do anything when it's called. It's called by the checkbox called "preview" with the onclick [xHTML] function. Heres the form code. I took out some buttons from this example which arn't useful to solving this problem. Thanks,Cold[code]<form action="'.DOMAIN.'source/action/exec.php" mothod="post" name="editform" id="editform" enctype="application/x-www-form-urlencoded"> <table cellpadding="0" border="0" width="100%"> <tr> <td>Title:</td> <td><input name="title" type="text" class="inputhelp"></td> </tr> <tr> <td></td> <td><input id="use" type="text" value="Help" readonly="true" class="inputhelp" /></td> </tr> <tr> <td>Text:</td> <td><textarea name="post" class="inputarea"></textarea></td> </tr> <tr> <td>Preview news post?</td> <td><input name="preview" id="preview" type="checkbox" onclick="javascript:Action()" value="checked"></td> </tr> <tr> <td><input name="type" type="hidden" value="news" /></td> <td><input name="submit" type="submit" value="Submit" class="submitbutton"/></td> </tr> </table></form>[/code] Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 31, 2006 Share Posted August 31, 2006 method is spelled wrong in your form. I tested your code and changing mothod to method seemed to do the trick Quote Link to comment Share on other sites More sharing options...
coldkill Posted September 1, 2006 Author Share Posted September 1, 2006 Yay! Works now. Can't believe it was a spelling mistake ¬¬. Thanks for the help.Cold[b]::SOLVED::[/b] Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted September 1, 2006 Share Posted September 1, 2006 No problem ... glad to help :)... Sometimes it takes another person to look at your code and point stuff like that out to you... I've done that so much in my 8 years as a programmer :). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.