PDA

View Full Version : Hidden Field Change



cs1h
10-01-2009, 01:08 PM
Hi,

I have a script that is meant to change the value of a hidden field and then change the css of form in which the hidden field is in to visible.

The css change works but the change value does not. Can any one help?

The java code:

<script language="javascript">

function ChangeHiddenValue() {

var MyElement = document.getElementById("target_url");
MyElement.value = "If you see this, it worked!";

document.getElementById('sign_in_light').style.display='block';document.getElementById('fade').style.display='block';

}
//-->
</script>


You click this link to run the program:

<a href = \"javascript:void(0)\" onclick = \"javascript:ChangeHiddenValue(this.value);\">Africa</a>

And the form:

<form action="xxxx.php" method="post" enctype="multipart/form-data" name="sign_in_light" id="sign_in_light" onsubmit="return rsv.validate(this, sign_in_rules)">
<div class="signinpatchformline"><span class="signinpatchformlinetext">Email:</span><input name="email" id="email"/>
<input type="hidden" name="target_url" id="target_url" value="" />
</div>
<div class="signinpatchformline"><span class="signinpatchformlinetext">Password:</span><input name="password" type="password" id="password"/>
</div>
<div class="signinpatchbutton"><span class="signinpatchformlineforgot">Forgot your password?</span>
<div class="buttonsright"><button type="submit" class="darkblue">Sign in</button></div></div>
</form>

All help is appreciated.

Cs1h

thetestingsite
10-01-2009, 01:16 PM
Try this instead:



<script type="text/javascript">

function ChangeHiddenValue(newval) {

document.getElementById("target_url").value = newval;

document.getElementById('sign_in_light').style.display='block';
document.getElementById('fade').style.display='block';
}
</script>


Hope this helps.

cs1h
10-01-2009, 01:47 PM
thanks,

that works great.

Cheers,
Cs1h