Jump to content


Photo

JS Problem ::SOLVED::


  • Please log in to reply
7 replies to this topic

#1 coldkill

coldkill
  • Members
  • PipPipPip
  • Advanced Member
  • 159 posts
  • LocationUnited Kingdom

Posted 30 August 2006 - 11:53 PM

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:
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"
	}
}
It's echoed from a PHP script and DOMAIN is changed for the current working directory of the site.

Thanks in advance,
Mike


You can learn alot from reading the manual

#2 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 31 August 2006 - 04:19 AM

for the a = bool ? true_val : false_val

all I see is a = val ? true_val : false_val... don't you need to test that first val against something before something is returned?
What is the CoronaMatrix?

#3 coldkill

coldkill
  • Members
  • PipPipPip
  • Advanced Member
  • 159 posts
  • LocationUnited Kingdom

Posted 31 August 2006 - 02:21 PM

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.


You can learn alot from reading the manual

#4 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 31 August 2006 - 04:17 PM

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?
What is the CoronaMatrix?

#5 coldkill

coldkill
  • Members
  • PipPipPip
  • Advanced Member
  • 159 posts
  • LocationUnited Kingdom

Posted 31 August 2006 - 04:59 PM

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

<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>



You can learn alot from reading the manual

#6 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 31 August 2006 - 10:53 PM

method is spelled wrong in your form.  I tested your code and changing mothod to method seemed to do the trick
What is the CoronaMatrix?

#7 coldkill

coldkill
  • Members
  • PipPipPip
  • Advanced Member
  • 159 posts
  • LocationUnited Kingdom

Posted 01 September 2006 - 12:20 AM

Yay! Works now. Can't believe it was a spelling mistake ¬¬.

Thanks for the help.
Cold

::SOLVED::


You can learn alot from reading the manual

#8 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 01 September 2006 - 06:31 AM

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 :).
What is the CoronaMatrix?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users