Jqgrid colNames set from a jsp hidden variable - jqgrid

I have a jqgrid whose column Name I wish to set from a jsp hidden variable.
<input type="hidden" name="columns" id="columns" value= "<%= finalColumns %>"></input>
This hidden id columns has the values:
value="'Master Code','Mst. Code Description','Master Code Status','Master Code Groups','Detail Code Groups','No. of Detail Codes','Length','Attribute Type','sample'" .
Now I am trying in my Javascript like
colNames:'['+$("#columns").val()+']',
But I am getting an alert box saying Length of colNames <> colModel.
I have checked, there are 9 col models and 9 values are present in the string. Where am I doing some mistake
UPDATE:SOLUTION :
I tried using
eval(('['+$("#columns").val()+']').toString()).
That solved the problem. I have to understand Why this solves the problem
Thanks anyways

Related

ASP-Classic Get information from dynamic field

I have an old ASP-page that contains a form but for some reason, a part of the code doens't work anymore.
The code was working before because I write the content of the form in a database and there I have values from the past.
A short description of my page:
I have a [select multiple]-field and when you select one (or more) option I create another input field (for every selected option a new fied). The ID of this field is FSRow_ + an edited value of de selected option (no spaces, commas, ...).
When I submit the form I want to read the content of my new fields so I can write this information to my database.
An example:
Suppose I have two selected options, to make it easy: "OptionA" and "OptionB", then I create two new fields (from the source code):
<input name="FSRow_OptionA" id="FSRow_OptionA" type="text">
<input name="FSRow_OptionB" id="FSRow_OptionB" type="text">
When I submit my form, I have this code:
if request.form()
...
getSelectedValues = split(request("OptionList"), ",")
for each li in getSelectedValues
li = replace(li, "'", "''")
li = replace(li, "||", ",")
fsrow = trim(request("FSRow_" & replace(replace(replace(replace(replace(trim(li), " ", ""), "&", ""), "+", ""), ",", ""), "|", "")))
if fsrow <> "" then
[write to DB with dynamic field]
else
[only write selected item]
end if
next
When I look in my database. I have only the information of the selected items (so, my i'm going in my else-code). Not the content of my dynamic field. So I suppose the variable "fsrow" is always empty, even if my new field contains some text.
My questions:
How can I get the content of my dynamic input field?
Any idea what could be wrong because it was working in july 2017 and didn't change anything.
[Not needed anymore, found the solution] I've tried to set an alert or write to the console to debug but this isn't working. How can I debug when I'm in my "for each"-loop?
Edit/Update 1:
As commented by Ricardo Pontual I can use "Response.End" in combination with "Response.Write" before.
If I do this:
Response.Write(li)
Response.Write("## FSRow_" & li & " ## ")
Response.Write("->" & request("FSRow_" & li))
I get this result:
OptionA## FSRow_OptionA ## ->
But in my form/input field I wrote "test" in the field with id "FSRow_OptionA"...
Edit/Update 2:
With a non-dynamic input field I can perfectly read and write the value in my database.
So it's realy a problem with the dynamic field...
Found the problem. This was very old code, from years ago that wasn't written by me, and the problem was the position of < form> and < /form>
Old code (NOT WORKING)
<table>
<form>
<tr>
...
</tr>
</form>
</table>
Changed the code by this:
<form>
<table>
<tr>
...
</tr>
</table>
</form>
I changed the order of < table> and < form> and it works now!

ASP Classic : Put a "variable" in a "Request.Form()"

I have a form that will send an array of data to an ASP page.
Let's say this array is called "matrix".
Usually, on the ASP receiving the form, I will write this out to retrieve the form inputs from the array "matrix".
Request.Form("matrix[]")(i) where i = 1, 2, 3 which are the elements in the array.
Let's say I want to do make a variable like this
a="matrix"
and I want to use this variable a and put it into the request form, instead of writing "matrix", so that it would look something like this
Request.Form(a[])(i)
How can it be done? For now, all my attempts are showing blank. e.g. when I try to make them appear on the page with response.write, nothing shows up.
Please help me or let me know if it cannot be done, I've been spending hours on this.
Request.Form("matrix[]") is taking a string value of "matrix[]" not an array of strings called "matrix".
So you need to do either
a = "matrix[]"
Request.Form(a)(i)
or
a = "matrix"
Request.Form(a & "[]")(i)
Unlike PHP which requires adding square brackets, in classic ASP you just have to give the same name to the elements you want to be combined into an array.
The HTML should be:
<input type="text" name="matrix" />
<input type="text" name="matrix" />
<input type="text" name="matrix" />
Then you can iterate over the submitted values like this:
For x=1 To Request.Form("matrix").Count
Response.Write("Value of matrix #" & CStr(x) & "is: " & Request.Form("matrix").Item(x))
Next
Note that all elements are included, even if user left them empty.

I trying to enter value to text area using vbscript but i am not able fill. text are tag dont have id it have only name

HTML code :
<textarea name="q", class="classname" placeholder="enter the search content"><\textarea>
and it is inside table and table is inside form I tried to use document.forms but I didn't get expected output.
I tried with document.getelementbyname("q").placeholder = "value"

get form values other than by name in codeigniter

hi i am using codeigniter . i have a form , there i add hidden fields dynamically . so every hidden field is <input type='hidden' name='hidden' value="+$(this).attr('title')+"> so the name is equal .
the problem is when i submit the form and try to get my hiden field values i can only get one hidden field value , because the names are same
i print my form values
print_r($this->input->post());
i have 2 hidden fields but i get only one
Array
(
[hidden] => march
[textbox] => march
[mysubmit] => Submit
)
i can change the name dynamically of hidden field when creating , but then i don't know exactly the name of my hidden field ,
how can i get hidden field values with same name ?? is there any way to get form values other than by name ?? i tried and can not find an answer , please help .............
You'll need to use brackets in your name attributes:
<input type='hidden' name='hidden[]'>
<!-- ^^^^ -->
This will allow PHP to accept multiple inputs with the same name as an array of values, so in this case, $_POST['hidden'] will return an array of strings.
By default they are indexed starting at 0, so $_POST['hidden'][0] will get you the first one, $_POST['hidden'][1] will get you the second, etc., however - you can explicitly index them if it's easier for you, either with numbers or strings.
<input type='hidden' name='hidden[first]'>
<input type='hidden' name='hidden[second]'>
Or:
<input type='hidden' name='hidden[0]'>
<input type='hidden' name='hidden[1]'>
You can nest these as deep as you want like hidden[first][1][], and they will be treated similarly to a PHP array when you get the $_POST values, but you need the brackets in the HTML.
Without brackets, only the last field's value will be available in the $_POST array. This is a PHP feature, Codeigniter can't do anything about it.

Validating input type number in html5

I want to restrict entry of input onto a field of type number such that input cannot be outside range of min-max specified in the html.
input type = "number" min = "1" max = "5"
Is there a way of outputting the number field without the text box and i would rather not use
"input type = range"
as slider does not show value currently selected
Please help.
Thanks.
Based on what you said, I suggest using a simple input text field and check it's value validity on submission via JavaScript (as #Kush mentions above). You could also check it as the user types, or moves focus away from that field.
<form>
Only 1 to 100 <input type="text" name="number" pattern="\d{1,2}(?!\d)|100" title="one to hundreed only">
<input type="submit">
</form>

Resources