Jump to content

JS Problem ::SOLVED::


coldkill

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/19217-js-problem-solved/
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/19217-js-problem-solved/#findComment-83597
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.